Say I have a pair of classes roughly like so:

class Parent(models.Model):
    name = models.CharField(maxlength=50)

class Child(models.Model):
    parent = models.ForeignKey(Parent)
    name = models.CharField(maxlength=50)
    order = models.IntegerField()

    class Meta:
        unique_together = [['parent', 'order'],]


Say that I have one Parent and three children:

Parent:
    name: "a parent"
Children:
    parent: "a parent"; name: "child1"; order: 1
    parent: "a parent"; name: "child2"; order: 2
   parent: "a parent";  name: "child3"; order: 3

And that Child can be edited inline to Parent in the admin.

Now, say I want to change the order of the children to look like this:
    parent: "a parent"; name: "child1"; order: 2
    parent: "a parent"; name: "child2"; order: 1
    parent: "a parent"; name: "child3"; order: 3

So I update the "order" fields in the inline, and try to save, but I
get an error for each of the updated children saying "Child with this
Parent and Order already exists" -- which makes sense because indeed
there are already children of that parent with orders 1 and 2... but
on the other hand is preventing me from updating them.

Any recommendations as to where to start in terms of working around
that?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to