Skip to content Skip to sidebar Skip to footer

"unknown Column X.id" Error In Django Using Existing Db

I am trying to create a model for an existsing DB. Using the output of manage.py inspectdb, My models.py file looks like this: from django.db import models ...some more stuff here

Solution 1:

There is always by default an implicit id field as auto incrementing primary key on every model. See primary_key in the Django docs how to change that field to some other name, but there needs to be one primary key (also in your table).

Also you may not want to call one of your fields super, since it is shadowing Python's built-in super in the class body. Might give you a hard time finding a bug some day.

Solution 2:

I'm not sure if you'r familiar with django-south?

It's a nice little tool that helps you migrate your data from one structure to another and also helps identify issues before commiting info to the table, causing less errors and debugging afterwards.

Post a Comment for ""unknown Column X.id" Error In Django Using Existing Db"