Monday, August 19, 2013

Is it possible to have 1-to-Many and 1-to-1 relationships for one specific table?

Is it possible to have 1-to-Many and 1-to-1 relationships for one specific table?
Because the database doesn't do what I wish for.


#_______________________________________________________________________________

class Altword(models.Model):
    #rosword = models.ForeignKey(Word)
    rosword = models.ForeignKey(Word, related_name='altword_rosword')
    alt_ros_word = models.CharField(max_length=200)
    wordy = models.OneToOneField(Word, related_name='wordy', primary_key=True)
    votes = models.IntegerField(default=0)
    pub_date = models.DateTimeField('date published')

    def __unicode__(self):
        return self.alt_ros_word
#_______________________________________________________________________________

--
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