gpt4 book ai didi

django-models - 如何添加新模型并使用 South 0.7.2 生成迁移?

转载 作者:行者123 更新时间:2023-12-01 08:18:26 24 4
gpt4 key购买 nike

我创建了一个新模型:

class RssFeed(models.Model):  
url = mdels.CharField(max_length=300)

$ python manage.py schemamigration forum --add-model RssFeed
  Traceback (most recent call last):
File "manage.py", line 13, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/site-packages/Django-1.2.3-py2.7.egg/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/site-packages/South-0.7.2-py2.7.egg/south/management/commands/schemamigration.py", line 134, in handle
for action_name, params in change_source.get_changes():
File "/usr/local/lib/python2.7/site-packages/South-0.7.2-py2.7.egg/south/creator/changes.py", line 397, in get_changes
real_fields, meta, m2m_fields = self.split_model_def(model, model_defs[model_key(model)])
File "/usr/local/lib/python2.7/site-packages/South-0.7.2-py2.7.egg/south/creator/freezer.py", line 58, in model_key
return "%s.%s" % (model._meta.app_label, model._meta.object_name.lower())
AttributeError: 'NoneType' object has no attribute '_meta'

最佳答案

我的语法是正确的,我创建模型的方式不是。

我已将所有模型放入目录/models

如果这样做,则必须将 Meta 添加到模型定义中:

class Meta:  
app_label = 'APP_NAME'

如果不这样做,Django 将无法发现新模型。

关于django-models - 如何添加新模型并使用 South 0.7.2 生成迁移?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4444222/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com