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.har...@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+unsubscr...@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
> <https://groups.google.com/d/msgid/django-users/cd0ad08f-f0fa-4884-94a8-3700577369bb%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Bala Subrahmanyam Varanasi
website: http://vabasu.com <vab...@gmail.com>
contact number: +919985415959

Github <https://github.com/Balu-Varanasi>  | Linkedin
<http://in.linkedin.com/in/vabasu> | Twitter <https://twitter.com/vabasu/>
| Facebook <https://facebook.com/vabasu>

-- 
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+unsubscr...@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.

Reply via email to