Models:

from django.db import models

class People(models.Model):
        name = models.CharField(max_length=30)

        class Meta:
                db_table = 'libs_peoples'

class Content(models.Model):
        title = models.CharField(max_length=30)
        peoples = models.ManyToManyField(People, through='Type')

        class Meta:
                db_table = 'libs_contents'

class Type(models.Model):
        people = models.ForeignKey(People)
        content = models.ForeignKey(Content)
        type = models.CharField(max_length=10)

        class Meta:
                db_table = 'libs_content_has_people'


Generated SQL:

BEGIN;
CREATE TABLE "libs_peoples" (
    "id" integer NOT NULL PRIMARY KEY,
    "name" varchar(30) NOT NULL
)
;
CREATE TABLE "libs_contents" (
    "id" integer NOT NULL PRIMARY KEY,
    "title" varchar(30) NOT NULL
)
;
CREATE TABLE "libs_content_has_people" (
    "id" integer NOT NULL PRIMARY KEY,
    "people_id" integer NOT NULL REFERENCES "libs_peoples" ("id"),
    "content_id" integer NOT NULL REFERENCES "libs_contents" ("id"),
    "type" varchar(10) NOT NULL
)
;
COMMIT;

How remove PK from table "libs_content_has_people" and don't use it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to