English 中文(简体)
Django - set Foreign 三、Kallite3号主要可推迟的外国关键制约因素
原标题:Django - set ForeignKey deferrable foreign key constraint in SQLite3

我似乎陷入了在Django的两个模式与作为我的后继储存而使用Lucite3这两种模式之间建立一种初步的推迟外国关键关系。

考虑这一简单的例子。 这就是models.py。 looks:

from django.db import models

class Investigator(models.Model):
    name = models.CharField(max_length=250)
    email = models.CharField(max_length=250)

class Project(models.Model):
    name = models.CharField(max_length=250)
    investigator = models.ForeignKey(Investigator)

这就是sqlall的产出。 looks:

BEGIN;
CREATE TABLE "moo_investigator" (
    "id" integer NOT NULL PRIMARY KEY,
    "name" varchar(250) NOT NULL,
    "email" varchar(250) NOT NULL
)
;
CREATE TABLE "moo_project" (
    "id" integer NOT NULL PRIMARY KEY,
    "name" varchar(250) NOT NULL,
    "investigator_id" integer NOT NULL REFERENCES "moo_investigator" ("id")
)
;
CREATE INDEX "moo_project_a7e50be7" ON "moo_project" ("investigator_id");
COMMIT;

“DEFERRABLE INITIALLY DEFERRED”在项目表内没有从*investigator_id*栏中删除。 我做了什么错误?

页: 1

问题回答

这种行为现在就没有了。 见





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签