[Fixed]-Should I create a model or just use a string

1๐Ÿ‘

โœ…

If you just have a string or a few strings which will be constant, just define it in settings.py. And use it like:

from django.conf import settings
print settings.my_string_1

If it is the case, you can save time by avoiding database access.

If you are going to use many strings which may vary over time, or need insertion, update or delete operations frequently, you have to use database to store it. If you already have a database like MySQL or postgres setup in the project, you can use it. If not, it is enough to use sqlite database if the database size is not going to be large enough.

Leave a comment