Django:cascade on_delete选项不工作 [英] Django: cascade on_delete option not working

查看:481
本文介绍了Django:cascade on_delete选项不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用django 1.2.4(通过 import django django.VERSION )的shell确认尝试使用 ForeignKeyField 上的 on_delete = models.SET_NULL 设置,但出现错误:

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

我正在做这个正确,或有什么tircks /问题,我想做什么?

Am I doing this properly or are there any tircks/issues with what I am trying to do?

感谢

推荐答案

on_delete 参数是Django 1.3中的新参数,它将在几周(或几天)内发布,预计 1月31日,但该日期可能会失效,因为尚未有候选人。)

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

当前trunk或Django 1.3的Beta 1对于开发是完全正常的,但我不会冒险在生产中使用它。

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:cascade on_delete选项不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆