#14179: django create table with capitalized chars
------------------------------------+---------------------------------------
Reporter: boris | Owner: nobody
Status: closed | Milestone:
Component: Uncategorized | Version: 1.2
Resolution: invalid | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
------------------------------------+---------------------------------------
Comment (by ramiro):
Replying to [comment:5 boris]:
> I expect that all table names are lowercase as described in tutorial
> http://docs.djangoproject.com/en/dev/intro/tutorial01/#activating-models
The name of the automatic intermediate table generated for a m2m field is
built from: a) the name of the app, b) the name of the table of the model
defining the m2m relationship and c) '''the name of the actual m2m field
itself''', e.g.:
{{{
#!python
from django.db import models
class ModelA(models.Model):
name = models.CharField(max_length=20)
class ModelB(models.Model):
name = models.CharField(max_length=20)
foo = models.ManyToManyField(ModelA, related_name='modelsb1')
BaR = models.ManyToManyField(ModelA, related_name='modelsb2')
}}}
{{{
BEGIN;CREATE TABLE "t14179_modela" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(20) NOT NULL
)
;
CREATE TABLE "t14179_modelb_foo" (
"id" integer NOT NULL PRIMARY KEY,
"modelb_id" integer NOT NULL,
"modela_id" integer NOT NULL REFERENCES "t14179_modela" ("id"),
UNIQUE ("modelb_id", "modela_id")
)
;
CREATE TABLE "t14179_modelb_BaR" (
"id" integer NOT NULL PRIMARY KEY,
"modelb_id" integer NOT NULL,
"modela_id" integer NOT NULL REFERENCES "t14179_modela" ("id"),
UNIQUE ("modelb_id", "modela_id")
)
;
CREATE TABLE "t14179_modelb" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(20) NOT NULL
)
;COMMIT;
}}}
So, there is no relation between this and the section of the tutorial you
quoted (it touches the topic of table names case only when it talks about
the tables created for the models):
''Table names are automatically generated by combining the name of the app
(polls) and the lowercase name of the model -- poll and choice. (You can
override this behavior.)''
If you need to have consistent all-lowercase names for the automatically
created intermediate table, then make sure you a) have a all-lowercase
name for the model table (either by using the auto generated one or by
using `Meta.db_table`) and b) define the m2m field with a all-lowercase
name.
--
Ticket URL: <http://code.djangoproject.com/ticket/14179#comment:6>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.