Open GoogleCodeExporter opened 8 years ago
/usr/lib/python2.6/site-packages/django/forms/models.py in _get_foreign_key
795. if fk_name:
796. fks_to_parent = [f for f in opts.fields if f.name == fk_name]
797. if len(fks_to_parent) == 1:
798. fk = fks_to_parent[0]
799. if not isinstance(fk, ForeignKey) or \
800. (fk.rel.to != parent_model and
801. fk.rel.to not in parent_model._meta.get_parent_list()):
***802. raise Exception("fk_name '%s' is not a ForeignKey to %s" % (fk_name,
parent_model)) ...
803. elif len(fks_to_parent) == 0:
804. raise Exception("%s has no field named '%s'" % (model, fk_name))
805. else:
806. # Try to discover what the ForeignKey from model to parent_model is
807. fks_to_parent = [
808. f for f in opts.fields
▼ Local vars
Variable Value
ForeignKey
<class 'django.db.models.fields.related.ForeignKey'>
can_fail
False
f
<multilingual.fields.TranslationForeignKey object at 0x9b7ba0c>
fk
<multilingual.fields.TranslationForeignKey object at 0x9b7ba0c>
fk_name
'master'
fks_to_parent
[<multilingual.fields.TranslationForeignKey object at 0x9b7ba0c>]
model
<class 'tunefiles.models.TuneFileTranslation'>
opts
<Options for TuneFileTranslation>
parent_model
<class 'tunefiles.models.TuneCommenter'>
Original comment by Person...@gmail.com
on 23 Aug 2009 at 6:12
SQLite is used.
[wiz@archy dtunes]$ python manage.py sqlall tunefiles
BEGIN;
CREATE TABLE "tunefiles_tunefile_translation" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(255) NOT NULL,
"description" text NOT NULL,
"language_id" integer NOT NULL,
"master_id" varchar(50) NOT NULL,
UNIQUE ("language_id", "master_id")
)
;
CREATE TABLE "tunefiles_tunefile" (
"code" varchar(50) NOT NULL PRIMARY KEY,
"file" varchar(100) NOT NULL,
"picture" varchar(100) NOT NULL,
"rating" smallint unsigned NOT NULL,
"active" bool NOT NULL,
"created_at" datetime NOT NULL
)
;
CREATE TABLE "tunefiles_tunecommenter_translation" (
"id" integer NOT NULL PRIMARY KEY,
"desc" varchar(100) NOT NULL,
"language_id" integer NOT NULL,
"master_id" varchar(50) NOT NULL,
UNIQUE ("language_id", "master_id")
)
;
CREATE TABLE "tunefiles_tunecommenter" (
"nick" varchar(50) NOT NULL PRIMARY KEY,
"avatar" varchar(100) NOT NULL,
"created_at" datetime NOT NULL,
"active" bool NOT NULL
)
;
CREATE TABLE "tunefiles_tunecomment_translation" (
"id" integer NOT NULL PRIMARY KEY,
"desc" varchar(100) NOT NULL,
"language_id" integer NOT NULL,
"master_id" integer NOT NULL,
UNIQUE ("language_id", "master_id")
)
;
CREATE TABLE "tunefiles_tunecomment" (
"code" smallint unsigned NOT NULL PRIMARY KEY,
"body" text NOT NULL,
"created_at" datetime NOT NULL,
"commenter_id" varchar(50) NOT NULL REFERENCES
"tunefiles_tunecommenter" ("nick"),
"tune_file_id" varchar(50) NOT NULL REFERENCES "tunefiles_tunefile" ("code"),
"active" bool NOT NULL
)
;
CREATE INDEX "tunefiles_tunefile_translation_language_id" ON
"tunefiles_tunefile_translation" ("language_id");
CREATE INDEX "tunefiles_tunefile_translation_master_id" ON
"tunefiles_tunefile_translation" ("master_id");
CREATE INDEX "tunefiles_tunecommenter_translation_language_id" ON
"tunefiles_tunecommenter_translation" ("language_id");
CREATE INDEX "tunefiles_tunecommenter_translation_master_id" ON
"tunefiles_tunecommenter_translation" ("master_id");
CREATE INDEX "tunefiles_tunecomment_translation_language_id" ON
"tunefiles_tunecomment_translation" ("language_id");
CREATE INDEX "tunefiles_tunecomment_translation_master_id" ON
"tunefiles_tunecomment_translation" ("master_id");
CREATE INDEX "tunefiles_tunecomment_commenter_id" ON
"tunefiles_tunecomment" ("commenter_id");
CREATE INDEX "tunefiles_tunecomment_tune_file_id" ON
"tunefiles_tunecomment" ("tune_file_id");
COMMIT;
Original comment by Person...@gmail.com
on 23 Aug 2009 at 6:28
Original issue reported on code.google.com by
Person...@gmail.com
on 23 Aug 2009 at 5:57