Hi Nicole,
Override the Friendship model's 'save' method to test the unique combination of (initiator, recipient).
Regards,
On 29 January 2015 at 08:27, Nicole Harris <n.harris@kabucreative.com.au> wrote:
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 :)
Nicole
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cd0ad08f-f0fa-4884-94a8-3700577369bb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Bala Subrahmanyam Varanasi
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOR1E%2BXZ89gtp9s--cJ_%3DaJkMzd1mNh2GZy3rgwMGGRj6TC5VA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment