拆分Django模型

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了拆分Django模型相关的知识,希望对你有一定的参考价值。

  1. # 1. Create a models folder under myApp.
  2.  
  3. # 2. Delete models.py and add a model_name.py file in the models folder for each model model_name.
  4.  
  5. # 3. Add the following to each model file :
  6.  
  7. class Meta:
  8. app_label = 'myApp'
  9.  
  10. # 4. Add a line in models/_init__.py_ for each model file :
  11.  
  12. from myModelFile import myModel

以上是关于拆分Django模型的主要内容,如果未能解决你的问题,请参考以下文章

拆分Django模型

如何在 django 中将一个表单字段拆分为模型的多个字段?

将 Django 管理“添加”界面中的字段拆分为其组成字段

在 django 模板中拆分字符串

Django:从 ModelAdmin 中访问模型实例?

如何构建我们的 django 模型