Thursday, September 12, 2013

Re: [Newbie] Self referencing models

On 2013-09-12, at 09:44 , Zoubeida wrote:
> Any help?
>
> Le samedi 8 novembre 2008 07:58:00 UTC+1, sunn a écrit :
>>
>> How do I make a foreign key to self?
>>
>> class Page(models.Model):
>> title = models.CharField(max_length=128)
>> display = models.CharField(max_length=64)
>> path = models.CharField(max_length=64)
>> sortorder = models.IntegerField()
>> parent = models.OneToOneField(Page) #Will not work neither will
>> parenttest = models.ForeignKey(Page) #nor
>> parenttest2 = models.ForeignKey(self)
>> def __unicode__(self):
>> return self.display
>>
>> any help appreciated!

The official documentation? https://docs.djangoproject.com/en/1.6/ref/models/fields/#foreignkey

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate