RE: model for legacy table without primary key

2011-12-30 Thread Sells, Fred
Thanks, that's the hack I was trying to remember. -Original Message- From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of akaariai Sent: Friday, December 30, 2011 1:06 PM To: Django users Subject: Re: model for legacy table without primary key

Re: model for legacy table without primary key

2011-12-30 Thread K.C. Smith
You said the four fields are unique together, but "userid" sounds like it should also be unique be itself, in which case it could be your PK. In either case, you are being a bit an4l about something that matters little. You should probably just create another column for an auto- incrementing PK.

Re: model for legacy table without primary key

2011-12-30 Thread akaariai
On Dec 30, 7:53 pm, Bill Beal wrote: > But it can't be a primary key if the values are not unique, right? > The four fields are unique together, but not necessarily individually. It is not a real primary key. The idea is to tell Django it is a primary key even if it is

Re: model for legacy table without primary key

2011-12-30 Thread Bill Beal
But it can't be a primary key if the values are not unique, right? The four fields are unique together, but not necessarily individually. Bill Beal On Fri, Dec 30, 2011 at 12:49 PM, akaariai wrote: > You could just define some arbitrary column as primary key. Primary > key

Re: model for legacy table without primary key

2011-12-30 Thread akaariai
You could just define some arbitrary column as primary key. Primary key doesn't play any important part in most select queries. It might be that some queries would break (like Django trying to group by the fake PK column when aggregating), but most things should just work. This is what I have done

model for legacy table without primary key

2011-12-30 Thread Sells, Fred
I thought I had read somewhere that it was possible to have a model for a legacy table without a primary key as long as the useage was read only and that the method was "filter" and not "get". I've been searching for quite a while now and all I can find indicates a primary key is mandatory for