Thanks for your fast reply.. You mean unique_together=(node_a, node_b)? No, that's not what I meant.
I want to make sure if someone has created Edge(node_a=x, node_b=y).save() he can't add Edge(node_a=y, node_b=x).save() because edge is a set of two distinct nodes. On Mar 9, 8:54 pm, Alex Gaynor <alex.gay...@gmail.com> wrote: > On Mon, Mar 9, 2009 at 8:52 AM, uprising <upris...@gmail.com> wrote: > > > Just reminded of a problem by this post, how can I validate a unique > > pair of nodes like this: > > > class Edge(models.Model): > > node_a: models.ForeignKey(Node) > > node_b: models.ForeignKey(Node) > > > I mean if I already have {"node_a": 1, "node_b": 2}, I can't add > > {"node_a": 2, "node_b": 1} > > How to enforce this restriction efficiently? > > Are you looking to maintain cross field uniqueness, if > so:http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together > > ALex > > -- > "I disapprove of what you say, but I will defend to the death your right to > say it." --Voltaire > "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---