I am using django 1.2.4 (Confirmed through the shell with import django
django.VERSION
) and am attempting to use the on_delete=models.SET_NULL
setting on a ForeignKeyField
but I get the error:
我正在使用django 1.2.4(通过shell通过导入django django. version进行确认),并试图使用on_delete=模型。在一个ForeignKeyField上SET_NULL设置,但是我得到了错误:
AttributeError: 'module' object has no attribute 'SET_NULL'
This is how I was attempting to use the setting:
这就是我尝试使用设置的方法:
relatedRec = models.ForeignKey(Record, null=True, blank=True, on_delete=models.SET_NULL)
The model was already created and I am now trying to alter it. I didnt think that would be a problem but maybe it is...
模型已经创建好了,我现在正在尝试修改它。我不认为那是个问题,但也许是……
Am I doing this properly or are there any tircks/issues with what I am trying to do?
我这样做是正确的,还是我正在做的事情有任何长篇大论的问题?
Thanks
谢谢
1 个解决方案
#1
3
The on_delete
argument is new in Django 1.3 which will be released in a couple of weeks (or days, it was projected for January 31, but that date could slip, since there is no release candidate yet).
on_delete参数是Django 1.3中的一个新参数,它将在几周后发布(或几天后发布,原计划在1月31日发布,但这个日期可能会推迟,因为还没有发布候选)。
Current trunk or the Beta 1 of Django 1.3 are perfectly fine for development, but I wouldn't risk using it in production just yet.
当前的主干或Django 1.3的Beta 1对于开发是完全没问题的,但是我还不会冒险在生产中使用它。
#1
3
The on_delete
argument is new in Django 1.3 which will be released in a couple of weeks (or days, it was projected for January 31, but that date could slip, since there is no release candidate yet).
on_delete参数是Django 1.3中的一个新参数,它将在几周后发布(或几天后发布,原计划在1月31日发布,但这个日期可能会推迟,因为还没有发布候选)。
Current trunk or the Beta 1 of Django 1.3 are perfectly fine for development, but I wouldn't risk using it in production just yet.
当前的主干或Django 1.3的Beta 1对于开发是完全没问题的,但是我还不会冒险在生产中使用它。