Django: cascade on_delete option not working

只谈情不闲聊 提交于 2019-12-11 06:07:07

问题


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:

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:


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).

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.



来源:https://stackoverflow.com/questions/4823182/django-cascade-on-delete-option-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!