Re: ForeignKey(unique=True) and ForeignRelatedObjectsDescriptor

2007-11-06 Thread Malcolm Tredinnick
On Tue, 2007-11-06 at 10:06 -0600, Jeremy Dunck wrote: > On 11/6/07, Thomas Guettler <[EMAIL PROTECTED]> wrote: > > > > You can use a property. Code not tested: > > Of course. I just have about 30 places to do that legwork, which seems silly. > > I understand Malcolm's argument, though. This i

Re: ForeignKey(unique=True) and ForeignRelatedObjectsDescriptor

2007-11-06 Thread Tai Lee
I had previously used OneToOne relationships and liked the auto mapping they did, as in the OP's example. I was told that OneToOne didn't work in some cases and was going away, and that I should use ForeignKey(unique=True) instead. If there are technical problems with OneToOne and ForeignKey(uniq

Re: ForeignKey(unique=True) and ForeignRelatedObjectsDescriptor

2007-11-06 Thread Marty Alchin
On 11/6/07, Jeremy Dunck <[EMAIL PROTECTED]> wrote: > > On 11/6/07, Thomas Guettler <[EMAIL PROTECTED]> wrote: > > > > You can use a property. Code not tested: > > Of course. I just have about 30 places to do that legwork, which seems silly. Well, you could write up a function to create the prop

Re: ForeignKey(unique=True) and ForeignRelatedObjectsDescriptor

2007-11-06 Thread Jeremy Dunck
On 11/6/07, Thomas Guettler <[EMAIL PROTECTED]> wrote: > > You can use a property. Code not tested: Of course. I just have about 30 places to do that legwork, which seems silly. I understand Malcolm's argument, though. This is why I asked rather than just making the small change in my local Dj

Re: ForeignKey(unique=True) and ForeignRelatedObjectsDescriptor

2007-11-06 Thread Thomas Guettler
Am Montag, 5. November 2007 18:47 schrieb Jeremy Dunck: > Consider: > > class Place(Model): > ... > > class Retaurant(Model): > place = ForeignKey(Place, unique=True) > You can use a property. Code not tested: class Place(Model): def get_restaurant(self): try:

Re: ForeignKey(unique=True) and ForeignRelatedObjectsDescriptor

2007-11-05 Thread Malcolm Tredinnick
On Mon, 2007-11-05 at 11:47 -0600, Jeremy Dunck wrote: > Consider: > > class Place(Model): > ... > > class Retaurant(Model): > place = ForeignKey(Place, unique=True) > > > Currently, if you have a place reference and want to get to the (0 or > 1) restaurant, you do something li

ForeignKey(unique=True) and ForeignRelatedObjectsDescriptor

2007-11-05 Thread Jeremy Dunck
Consider: class Place(Model): ... class Retaurant(Model): place = ForeignKey(Place, unique=True) Currently, if you have a place reference and want to get to the (0 or 1) restaurant, you do something like this: r = place.restaurant_set.get() Slightly more idiomatic w/ relat