首先,我最近从Django 1.6升级到1.8,从未使用过South,因此我不熟悉迁移.
我跑了:
> python manage.py makemigrations myapp
> python manage.py migrate --fake initial
Run Code Online (Sandbox Code Playgroud)
使用现有MySQL表为我的模型创建初始迁移.到目前为止一切似乎都很好
然后我在我的模型中添加了一个IntegerField:
new_integer_field = models.IntegerField(default = 50) #can include blank=True, null=True; seems to make no difference
Run Code Online (Sandbox Code Playgroud)
现在我跑的时候:
>python manage.py makemigrations myapp
Run Code Online (Sandbox Code Playgroud)
我明白了
django.db.utils.OperationalError: (1054, "Unknown column 'myapp_mymodel.new_integer_field' in 'field list'")
Run Code Online (Sandbox Code Playgroud)
追溯(从问题发生的地方开始)是:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File ".../django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File ".../django/core/management/__init__.py", line 312, in execute
django.setup()
File ".../django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File ".../django/apps/registry.py", …Run Code Online (Sandbox Code Playgroud) 在Django Admin中,当我单击下拉列表旁边的添加(+)按钮时,我想使用当前记录中的数据来填充外键记录的字段.
例如,我正在查看X的实例,其中包含a,b和c的字段以及外键Y.Y还包含a,b和c的字段,因此当我单击"添加"按钮时在X实例中,我希望使用X实例中的值填充新Y实例的a,b和c字段.
显然,如果我只是在管理员中添加"添加新Y",这些字段就不会预先填充!
我搜索了一下但没有用!
有人有成功吗?
(我在Python 2.6中使用django 1.3;我认为这里不需要任何代码片段.)