Tuesday, January 4, 2011

Problem with models

I have model of text, like that:

class Text(models.Model):
text = models.CharField()
user = models.ForeignKey(User) #author

And i need to compare two of texts, so i need table like this:

class Compare(models.Model):
text1 = models.ForeignKey(Text)
text2 = models.ForeignKey(Text)
user = models.ForeignKey(User) #who compared

Now i want to get from Text table two random texts and at least one of
them cant be compared yet by given user, how can i do this?

if I try reverse relation compares_set, it doesnt work cause' i have
two foreignkey of same model.
I cant give manaytomanyfield in Text through Compare because i cant
make symmetrical reference with intermediate table.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment