How to access model's class level variable in data migration?

后端 未结 2 805

Here is my model.

Poll(models.Model):
   title = models.CharField(max_length=1024)
   MY_VAR = [\'my_class_level_attribute\'] # I want to access this
         


        
2条回答
  •  無奈伤痛
    2021-02-14 20:35

    You should be able to import the model

    from my_app.models import Poll
    

    If you do this, you shouldn't delete the Poll model or the MY_VAR attribute, otherwise your migrations will stop working.

提交回复
热议问题