Re: Problem with ForeignKey to an abstract class

2010-12-01 Thread Marc Aymerich
On Wed, Dec 1, 2010 at 12:48 PM, Ferran wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA256 > > Hello everyone, > > I want to have foreign keys to parent model on a manytomany > intermediate table (through) to have unique entries for that domain. > > The problem is i want this parent mod

Re: Problem with ForeignKey to an abstract class

2010-12-01 Thread Ferran
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 On 01/12/10 12:48, Ferran wrote: > I've thought maybe i can implement contacts and ns fields in both > DomainOwned and DomainPending, using generic relationships, but it > does not seems right to me. Shame on me. This is the right way to do it, the

Problem with ForeignKey to an abstract class

2010-12-01 Thread Ferran
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Hello everyone, I want to have foreign keys to parent model on a manytomany intermediate table (through) to have unique entries for that domain. The problem is i want this parent model class to be an abstract one, because i don't ever want to inst

Re: Problem with ForeignKey()

2010-09-23 Thread Tom Evans
First thought is "You haven't provided anywhere near enough context". Second thought is "That is how it works, so you're doing something else wrong. See #1". class PropertyValue(BaseModel): value = models.CharField(max_length=256) prop = models.ForeignKey('Property') parent = models.Foreign

Re: Problem with ForeignKey()

2010-09-22 Thread Yo-Yo Ma
Any thoughts on this? On Sep 22, 10:47 am, Yo-Yo Ma wrote: > Anyone know how to do this? > > On Sep 21, 10:35 pm, Yo-Yo Ma wrote: > > > > > I have a model with: > > > parent = ForeignKey('self', blank=True, null=True) > > > In that model I've overridden clean() to contain: > > > if self.parent:

Re: Problem with ForeignKey()

2010-09-22 Thread Yo-Yo Ma
Anyone know how to do this? On Sep 21, 10:35 pm, Yo-Yo Ma wrote: > I have a model with: > > parent = ForeignKey('self', blank=True, null=True) > > In that model I've overridden clean() to contain: > > if self.parent: >     # Do some stuff > > It raises an attribute error saying that parent.pk doe

Problem with ForeignKey()

2010-09-21 Thread Yo-Yo Ma
I have a model with: parent = ForeignKey('self', blank=True, null=True) In that model I've overridden clean() to contain: if self.parent: # Do some stuff It raises an attribute error saying that parent.pk doesn't exist. How can I get around this. Note that my foreign key is recursive. --

Re: Problem with ForeignKey field

2010-02-28 Thread Ben Dowling
OK thanks. I didn't realise that was the implication of the related_name field. All working as expected now. Thanks, Ben On 28 Feb, 13:16, Daniel Roseman wrote: > On Feb 28, 11:46 am, Ben Dowling wrote: > > > > > I have a Thread and a Message model, as defined below: > > > class Thread(models.M

Re: Problem with ForeignKey field

2010-02-28 Thread Daniel Roseman
On Feb 28, 11:46 am, Ben Dowling wrote: > I have a Thread and a Message model, as defined below: > > class Thread(models.Model): >         modified = models.DateTimeField(auto_now=True, auto_now_add=True) > > class Message(models.Model): >         subject = models.CharField(max_length = 100) >    

Problem with ForeignKey field

2010-02-28 Thread Ben Dowling
I have a Thread and a Message model, as defined below: class Thread(models.Model): modified = models.DateTimeField(auto_now=True, auto_now_add=True) class Message(models.Model): subject = models.CharField(max_length = 100) thread = models.ForeignKey(Thread, related_name='t