Platform: Python 2.5, Django development root, PostgreSQL 8.4, Windows Vista Ultimate SP2. Procedure: Django Documentation, Release 1.0, link text, Section 34.2, Providing initial SQL data.
CODE:
models.py:
class aisc_customary(models.Model):
MTYPE = models.CharField(max_length=4, editable=False,
help_text="Shape type, e.g. W, C, L, etc.")
EDI_STD_NOMENCLATURE = models.CharField(max_length=26, editable=False,
help_text="EDI shape designation")
AISC_MANUAL_LABEL = models.CharField(max_length=26, editable=False, primary_key=True,
help_text="AISC Manual label")
T_F = models.CharField(max_length=1, editable=False,
help_text="Special note flag, T or F")
W = models.FloatField(editable=False,
help_text="Nominal weight, lbs/ft")
... (45 more FloatFields)
application1/sql/aisc_customary.sql:
INSERT INTO application1_aisc_customary (MTYPE, EDI_STD_NOMENCLATURE, AISC_MANUAL_LABEL, T_F, W, A, D, HT, OD, BF, B, ID, TW, TF, T, TNOM, TDES, KDES, KDET, K1, X, Y , E0, XP, YP, BF_2TF, B_T, H_TW, H_T, D_T, IX, ZX, SX, RX, IY, ZY, SY, RY, RZ, J, CW, C, WNO, SW, QF, QW, RO, H, TAN_ALPHA, QS) VALUES ('W', 'W44X335', 'W44X335', 'F', 335, 98.5, 44.0, 0, 0, 15.9, 0, 0, 1.03, 1.77, 0, 0, 0.00, 2.56, 2.63, 1.31, 0.00, 0.00, 0.00, 0.00, 0.00, 4.50, 0.00, 38.0, 0.00, 0.00, 31100, 1620, 1410, 17.8, 1200, 236, 150, 3.49, 0.00, 74.7, 535000, 0.00, 168, 1180, 278, 805, 0.00, 0.00, 0.00, 0.00);
INSERT INTO application1_aisc_customary (MTYPE, EDI_STD_NOMENCLATURE, AISC_MANUAL_LABEL, T_F, W, A, D, HT, OD, BF, B, ID, TW, TF, T, TNOM, TDES, KDES, KDET, K1, X, Y , E0, XP, YP, BF_2TF, B_T, H_TW, H_T, D_T, IX, ZX, SX, RX, IY, ZY, SY, RY, RZ, J, CW, C, WNO, SW, QF, QW, RO, H, TAN_ALPHA, QS) VALUES ('W', 'W44X290', 'W44X290', 'F', 290, 85.4, 43.6, 0, 0, 15.8, 0, 0, 0.865, 1.58, 0, 0, 0.00, 2.36, 2.44, 1.25, 0.00, 0.00, 0.00, 0.00, 0.00, 5.02, 0.00, 45.0, 0.00, 0.00, 27000, 1410, 1240, 17.8, 1040, 205, 132, 3.49, 0.00, 50.9, 461000, 0.00, 166, 1040, 248, 701, 0.00, 0.00, 0.00, 0.00);
INSERT INTO application1_aisc_customary (MTYPE, EDI_STD_NOMENCLATURE, AISC_MANUAL_LABEL, T_F, W, A, D, HT, OD, BF, B, ID, TW, TF, T, TNOM, TDES, KDES, KDET, K1, X, Y , E0, XP, YP, BF_2TF, B_T, H_TW, H_T, D_T, IX, ZX, SX, RX, IY, ZY, SY, RY, RZ, J, CW, C, WNO, SW, QF, QW, RO, H, TAN_ALPHA, QS) VALUES ('W', 'W44X262', 'W44X262', 'F', 262, 76.9, 43.3, 0, 0, 15.8, 0, 0, 0.785, 1.42, 0, 0, 0.00, 2.20, 2.25, 1.19, 0.00, 0.00, 0.00, 0.00, 0.00, 5.57, 0.00, 49.6, 0.00, 0.00, 24100, 1270, 1110, 17.7, 923, 182, 117, 3.47, 0.00, 37.3, 405000, 0.00, 165, 928, 223, 630, 0.00, 0.00, 0.00, 0.00);
... (1965 more lines like this)
Django development server works fine and PostgreSQL server is working and answers queries about data of other models when the troublesome initial data file is removed from its standard path.
With previous versions of bad tables dropped using pgAdmin III, console command "python manage.py syncdb" yields this error:
Creating table application1_aisc_customary Installing custom SQL for application1.aisc_customary model Failed to install custom SQL for application1.aisc_customary model: column "mtype" of relation "application1_aisc_customary" does not exist LINE 1: INSERT INTO application1_aisc_customary (MTYPE, EDI_STD_NOME...
A carat points to the M of MTYPE. The error notwithstanding, column (upper case) MTYPE does exist, as may be seen using pgAdmin III. Note that Django admin reports the table, but it has no records.
I've tried unicode and ANSI encoding for the SQL, taking editable=False off the model attributes, and lower case names for everything but the model attributes. Maybe I'm missing some preparatory SQL statement. I'm striking out. I would be extremely grateful for an enlightening response. Thanks in advance for your help.
09/21/09: For the record, zalew's answer is correct. Lower-case field names are needed. I also had to change one field name, id (inside diameter) to i_d in order to correct the obvious conflict with the primary key. I changed od to o_d to match. Problem solved.