On 10/19/06, flynnguy <[EMAIL PROTECTED]> wrote:
>
> Yes, but don't I still need to specify a primary key in django?

Yes you do, but you can nominate any field in your model as the
primary key - you don't have to use 'id'. If you add a
primary_key=True argument to the definition of any field, it will be
treated as the primary key.

The purpose of this approach is to create a Django definition of a
model that would produce an SQL table that functions the same (at a
query level) to the SQL table that you already have. To emit basic
searches, you don't need to know exactly which field is the primary
key - you only need to know the name and type of the available table
columns.

This approach isn't perfect. There are a few places it will fall down.
Anything relying upon the primary key for identification will fail -
for example making foreign key queries. However, basic queries and
model modifications should be possible.

If you're having difficulties, can you provide the SQL schema you are
trying to use, and the result of running manage.py inspectdb on that
schema?

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to