14👍
✅
Django doesn’t enforce choices on a database level, it only uses them for the presentation of the widgets and in validation. If you want them a bit more ‘dynamic’, for example to have different ones on different servers you could define them via settings.py
:
from django.conf import settings
COLOR_CHOICES = getattr(settings, 'COLOR_CHOICES',(
('R', 'Red'),
('B', 'Blue'),
('G', 'Green'),
))
Then you could define different choices in your settings.py
(no need for any database migration!).
2👍
The field is models.CharField
so the database will treat it like any other models.CharField
set up in django 🙂
No, it doesn’t enforce choices / you don’t need to touch your DB.
- Custom columns in django_tables2
- Dynamic Django Mail Configuration
- Where do I install Twitter Bootstrap for Django – main or static folder?
- Django object is not JSON serializable error after upgrading django to 1.6.5
- Django serving media files (user uploaded files ) in openshift
Source:stackexchange.com