On Wednesday, February 20, 2013 6:53:39 AM UTC-6, laxglx wrote:
Hello all,--
I just run a command to Add foreign key to the existing table. and the command was like this:
ALTER TABLE acfs_subscriptionmaster ADD CONSTRAINT FK_Formats FOREIGN KEY (id) REFERENCES acfs_formats (id) MATCH FULL;
It has got executed. but giving error on the interface
column acfs_subscriptionmaster.FK_Formats_id does not exist
LINE 1: ...ccountmaster"."id") INNER JOIN "acfs_formats" ON ("acfs_subs...
What could be the reason, What Should I do to solve this. I can't DROP Table. ?
my models.py looks like this :
class SubscriptionMaster(models.Model):
"""
"""
uid = models.TextField(blank=True, null=True)
FK_SubsType = models.ForeignKey(SubscriptionType)
FK_Product = models.ForeignKey(ProductMaster)
FK_Formats = models.ForeignKey(Formats) <<---------------------------------- Added this field in models.py ccs_minimum_price = models.TextField(blank=True, null=True)
ccs_maximum_price = models.TextField(blank=True, null=True)
ccs_Increment_type = models.TextField(blank=True, null=True)
ccs_minimum_increment = models.TextField(blank=True, null=True)
ccs_maximum_increment = models.TextField(blank=True, null=True)
ccs_default_offer = models.TextField(blank=True, null=True)
Checked SQL Got created by python manage.py sqlall acfs
This is my table :
CREATE TABLE "acfs_subscriptionmaster" (
"id" serial NOT NULL PRIMARY KEY,
"uid" text,
"FK_SubsType_id" integer NOT NULL REFERENCES "acfs_subscriptiontype" ("id") DEFERRABLE INITIALLY DEFERRED,
"FK_Product_id" integer NOT NULL REFERENCES "acfs_productmaster" ("id") DEFERRABLE INITIALLY DEFERRED,
"FK_Formats_id" integer NOT NULL REFERENCES "acfs_formats" ("id") DEFERRABLE INITIALLY DEFERRED, <--------------This field has got created here
"ccs_minimum_price" text,
"ccs_maximum_price" text,
"ccs_Increment_type" text,
"ccs_minimum_increment" text,
"ccs_maximum_increment" text,
"ccs_default_offer" text,
);
Also its howing indexes like this :
CREATE INDEX "acfs_subscriptionformats_FK_Format_id" ON "acfs_subscriptionformats" ("FK_Format_id");
CREATE INDEX "acfs_subscriptionmaster_FK_SubsType_id" ON "acfs_subscriptionmaster" ("FK_SubsType_id");
CREATE INDEX "acfs_subscriptionmaster_FK_Product_id" ON "acfs_subscriptionmaster" ("FK_Product_id");
CREATE INDEX "acfs_subscriptionmaster_FK_Formats_id" ON "acfs_subscriptionmaster" ("FK_Formats_id");
Looks like error is field has not got created in actual database :
python manage.py dbshell
acfsdb1=# SELECT * FROM acfs_subscriptionmaster;
id | uid | FK_SubsType_id | FK_Product_id | ccs_minimum_price | ccs_maximum_price | ccs_Increment_type | ccs_minimum_increment | ccs_maximum_increment | ccs_default_of
fer | fix_startdatetime | fix_expiydatetime | fix_price | dur_period | wd_field_01 | wd_field_02 | wd_field_03 | wd_field_04 | wd_field_05 | flag_field_01 | created_dat
e_time | modified_date_time
----+-----+----------------+---------------+---------------- ---+-------------------+------ --------------+--------------- --------+--------------------- --+---------------
----+-------------------+-------------------+-----------+--- ---------+-------------+------ -------+-------------+-------- -----+-------------+---------- -----+------------
-------+--------------------
(0 rows)
This is my DJANGO - Python versions
postgres 9.1
Django Version: 1.2.7 Exception Type: DatabaseError Exception Value: column acfs_subscriptionmaster.FK_Format_id does not exist LINE 1: ...ccountmaster"."id") INNER JOIN "acfs_formats" ON ("acfs_subs... ^ Exception Location: /usr/lib/python2.6/site- packages/django/db/backends/ postgresql_psycopg2/base.py in execute, line 44 Python Executable: /usr/bin/python Python Version: 2.6.6
Traceback Variables (see at the bottom for the error)
▼ Local vars args ()e ProgrammingError('column acfs_subscriptionmaster.FK_Format_id does not exist\nLINE 1: ...ccountmaster"."id") INNER JOIN "acfs_formats" ON ("acfs_subs...\n ^\n',) query 'SELECT "acfs_subscriptionmaster"."id", "acfs_subscriptionmaster"." uid", "acfs_subscriptionmaster"."FK_ SubsType_id", "acfs_subscriptionmaster"."FK_ Product_id", "acfs_subscriptionmaster"."FK_ Format_id", "acfs_subscriptionmaster"." ccs_minimum_price", "acfs_subscriptionmaster"." ccs_maximum_price", "acfs_subscriptionmaster"." ccs_Increment_type", "acfs_subscriptionmaster"." ccs_minimum_increment", "acfs_subscriptionmaster"." ccs_maximum_increment", "acfs_subscriptionmaster"." ccs_default_offer", "acfs_subscriptionmaster"." fix_startdatetime", "acfs_subscriptionmaster"." fix_expiydatetime", "acfs_subscriptionmaster"." fix_price", "acfs_subscriptionmaster"." dur_period", "acfs_subscriptionmaster"."wd_ field_01", "acfs_subscriptionmaster"."wd_ field_02", "acfs_subscriptionmaster"."wd_ field_03", "acfs_subscriptionmaster"."wd_ field_04", "acfs_subscriptionmaster"."wd_ field_05", "acfs_subscriptionmaster"." flag_field_01", "acfs_subscriptionmaster"." created_date_time", "acfs_subscriptionmaster"." modified_date_time", "acfs_subscriptiontype"."id", "acfs_subscriptiontype"." substype", "acfs_subscriptiontype"."wd_ field_01", "acfs_subscriptiontype"."wd_ field_02", "acfs_productmaster"."id", "acfs_productmaster"."uid", "acfs_productmaster"."FK_ Account_id", "acfs_productmaster"."product_ type", "acfs_productmaster"."product_ name", "acfs_productmaster"."product_ description", "acfs_productmaster"."product_ code", "acfs_productmaster"."author", "acfs_productmaster"."blurb", "acfs_productmaster"."title", "acfs_productmaster"." subtitle", "acfs_productmaster"." keywords", "acfs_productmaster"."subject" , "acfs_productmaster"." contributor", "acfs_productmaster"." publisher", "acfs_productmaster"." published_date", "acfs_productmaster"." identifier", "acfs_productmaster"."genre", "acfs_productmaster"."title_ sort", "acfs_productmaster"."author_ sort", "acfs_productmaster"." relation", "acfs_productmaster"."pricing_ type", "acfs_productmaster"."is_ empty", "acfs_productmaster"." purchase", "acfs_productmaster"." subscription", "acfs_productmaster"." copyright", "acfs_productmaster"."created_ by", "acfs_productmaster"." modified_by", "acfs_productmaster"."workuid" , "acfs_productmaster"."wd_ field_01", "acfs_productmaster"."wd_ field_02", "acfs_productmaster"."wd_ field_03", "acfs_productmaster"."wd_ field_04", "acfs_productmaster"."wd_ field_05", "acfs_productmaster"."flag_ field1", "acfs_productmaster"."flag_ field2", "acfs_productmaster"."created_ date_time", "acfs_productmaster"." modified_date_time", "acfs_accountmaster"."id", "acfs_accountmaster"."uid", "acfs_accountmaster"."account_ name", "acfs_accountmaster"."account_ url", "acfs_accountmaster"."account_ type", "acfs_accountmaster"."active", "acfs_accountmaster"." currency", "acfs_accountmaster"." organization", "acfs_accountmaster"." address1", "acfs_accountmaster"." address2", "acfs_accountmaster"."city", "acfs_accountmaster"."postal_ zip", "acfs_accountmaster"."state", "acfs_accountmaster"."country" , "acfs_accountmaster"."contact_ name", "acfs_accountmaster"."contact_ mobile", "acfs_accountmaster"."contact_ email", "acfs_accountmaster"." language", "acfs_accountmaster"."maximum_ users", "acfs_accountmaster"."maximum_ documents", "acfs_accountmaster"."expiry_ date", "acfs_accountmaster"."wd_ field_01", "acfs_accountmaster"."wd_ field_02", "acfs_accountmaster"."wd_ field_03", "acfs_accountmaster"."wd_ field_04", "acfs_accountmaster"."wd_ field_05", "acfs_accountmaster"."flag_ field1", "acfs_accountmaster"."flag_ field2", "acfs_accountmaster"."created_ date_time", "acfs_accountmaster"." modified_date_time", "acfs_accountmaster"."created_ by", "acfs_accountmaster"." modified_by", "acfs_formats"."id", "acfs_formats"."uid", "acfs_formats"."format_name", "acfs_formats"."format_type", "acfs_formats"."subscription", "acfs_formats"."wd_field_01", "acfs_formats"."wd_field_02", "acfs_formats"."created_date_ time", "acfs_formats"."modified_date_ time" FROM "acfs_subscriptionmaster" INNER JOIN "acfs_subscriptiontype" ON ("acfs_subscriptionmaster"." FK_SubsType_id" = "acfs_subscriptiontype"."id") INNER JOIN "acfs_productmaster" ON ("acfs_subscriptionmaster"." 'FK_Product_id" = "acfs_productmaster"."id") INNER JOIN "acfs_accountmaster" ON ("acfs_productmaster"."FK_ Account_id" = "acfs_accountmaster"."id") INNER JOIN "acfs_formats" ON ("acfs_subscriptionmaster"." FK_Format_id" = "acfs_formats"."id") ORDER BY "acfs_subscriptionmaster"."id" DESC self <django.db.backends.postgresql_psycopg2.base. CursorWrapper object at 0x7ff73e389d50>
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment