inspectdb isn't perfect - it's just a starting point that will
hopefully remove the need to do a lot of typing. It is entirely
expected that you will need to tweak the model provided by inspectdb.
If inspectdb is producing an extra 'id' field in the model it
suggests, just delete that field from the suggested model.
However, because of the way Django operates, you will need to nominate
one of the fields in your model to be the primary key. In your case,
I'm guessing that inspectdb can't find an obvious candidate for the
primary key, so it has given up and put an extra 'id' field into the
definition it suggests.
You can choose any field you want to be the primary key (provided it
actually contains unique data). It doesn't matter what that field is
called - it just needs to set the primary_key attribute to True. For
example, if one of your models has a 'name' field that could be used
as a primary key, you would use a definition something like:
name = models.CharField(max_length=40, primary_key=True)
Yours,
Russ Magee %-)
This isn't going to work very well with Django. There are a lot of
places in Django that use the primary key on a table to access it. So
tables without primary keys at all aren't supported (or possible).
> I want
> to disable django's automatic add the id key with primary key feature.
>
> The primary key field in old table doesn't exist, and I checked it's
> not in the models.py too.
Either you specify the primary key manually or Django adds it
automatically. There's no option to avoid one altogether.
Regards,
Malcolm