python - db model - fields or dictionary of fields -
i'm working on project in django. in models have class object
, want add settings object
(object
stored in database).
i consider 2 options:
- add every settings attributes class
object
class members - add dictionary settings attributes class
object
1 class member
how think option better? or maybe have one.
you can add model obj new class, , add there thing like. (look @ django class meta)
class yourmodel(model): field_one = models.charfield(max_length=50, null=false, blank=false, default="") field_two = models.charfield(max_length=50, null=false, blank=false, default="") class yourmeta: settings_field_one = 'any value..' settings_field_two = 'any value..'
and can access like:
yourmodel.yourmeta.settings_field_one
Comments
Post a Comment