multi-select admin filter for RelatedFields

2006-05-10 Thread Marc Boeren
Hi, I've hacked my way into the admin filters, changing the RelatedFilterSpec from a single-select filter to a multi-select filter. I can now filter on multiple values from the same ManyToMany or ForeignKey relationship, i.e. if I add 'groups' to the list_filter for Users, I can select all users

Database API - Foreign Keys - how to descend the "tree"

2006-05-10 Thread lifeisgood
If I have a models file class City(models.Model): # ... class Person(models.Model): # ... hometown = models.ForeignKey(City) class Book(meta.Model): # ... author = models.ForeignKey(Person) then select_related will allow me to easily find all persons and citys related to a

Re: composite primary key

2006-05-10 Thread James Bennett
On 5/10/06, Michael Radziej <[EMAIL PROTECTED]> wrote: > I think you'll run into many problems since everything expects that > it can do a get(pk=...), which wouldn't work. Well, considering that Django explicitly advertises zero support for this situation, I'd say getting *anything* to work is p

Re: composite primary key

2006-05-10 Thread Honza Král
if you specify one of the fields to be the primary key, you would probably violate the constraint (PK must be unique on itself)... It would not work as a many-to-many: 1,2 2,2 2,1 -- couldn't do that, violates PK On 5/10/06, Michael Radziej <[EMAIL PROTECTED]> wrote: > > > Am 10.05.2006 um 21:27 s

Re: composite primary key

2006-05-10 Thread Michael Radziej
Am 10.05.2006 um 21:27 schrieb James Bennett: > > On 5/10/06, Michael Radziej <[EMAIL PROTECTED]> wrote: >> But I need this for an ugly existing database (tm) that I cannot >> touch. And, of course, it's a ManyToManyField in very open disguise, >> but it has additional attributes. Unfortunately,

Re: composite primary key

2006-05-10 Thread James Bennett
On 5/10/06, Michael Radziej <[EMAIL PROTECTED]> wrote: > But I need this for an ugly existing database (tm) that I cannot > touch. And, of course, it's a ManyToManyField in very open disguise, > but it has additional attributes. Unfortunately, a ManyToManyField is > based on an association table w

Re: composite primary key

2006-05-10 Thread Michael Radziej
Am 10.05.2006 um 20:09 schrieb James Bennett: > You'll probably want to read this and save yourself some time: > > http://www.djangoproject.com/documentation/faq/#do-django-models- > support-multiple-column-primary-keys This indicates that you could simply ignore the problem and add a composi

Re: composite primary key

2006-05-10 Thread Brantley Harris
What you describe is a ManyToManyField in disguise. A thinly veiled disguise. Perhaps you might want to rethink what you actually need. Be carefull not to think too much within the frame of Rational Databases. On 5/10/06, Michael Radziej <[EMAIL PROTECTED]> wrote: > > Hi, > > I need to be able

Re: composite primary key

2006-05-10 Thread James Bennett
On 5/10/06, Michael Radziej <[EMAIL PROTECTED]> wrote: > I need to be able to use models like this: > > class Xlwzl(models.Model): > xl = IntegerField(primary_key=True) > wzl = IntegerField(primary_key=True) You'll probably want to read this and save yourself some time: http://ww

composite primary key

2006-05-10 Thread Michael Radziej
Hi, I need to be able to use models like this: class Xlwzl(models.Model): xl = IntegerField(primary_key=True) wzl = IntegerField(primary_key=True) (they are actually ForeignKeys, but this probably doesn't matter. This is probably also a good start for ManyToManyFields with an