Wednesday, January 28, 2015

Validation on two user foreign keys

Hi All,

I have a model called 'Friendship' that includes two foreign keys to User.  One is the 'initiator' of the Friendship, the other the 'recipient'.
I want to make sure the Friendship only exists once regardless of who is the recipient and who is the initiator.
Any thoughts on the best way to validate for this?
Should I create a custom manager and override .objects.create() ?

Thanks for your time :)

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
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment