You probably can't do this without breaking into the internals of Django. The syncdb checks the meta object for each model to get a list of the created fields, which is created during the construction of the class through the class metaclass django.db.models.Model :
class MyModel(models.Model): my_filed = models.CharField(...)
After the class is completed, for example. after DEDENT after the class operator, the meta object is fixed (it is not affected by a change in the model class), and you will have to hack the meta (which, of course, is possible) to add dynamic fields. But since you're messing around with internal objects here, this may make your application incompatible with future releases of Django.
The question remains: why do you need to do this? Because database tables are usually created only once when you deploy your application, the models are kind of βstaticβ.
source share