Maybe this would help?

http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together


On Jan 18, 10:40 am, Konstantin <ktechli...@gmail.com> wrote:
> Hello!
>
> First of all I want to apologize for maybe very basic question, but I
> newbie in django and web coming from c/c++ world.
>
> I have two models:
>
> class Box(models.Model):
>     description = models.CharField(max_length=250)
>     id = models.IntegerField(primary_key=True)
>
>     def __unicode__(self):
>         return self.description
>
> class Item(models.Model):
>     title = models.CharField(max_length=500)
>     box = models.ForeignKey(Box)
>     label = models.IntegerField()
>
>     def __unicode__(self):
>         return self.title
>
> What I want is to enforce in some way uniqueness of pair (label, box)
> for every item. So there may be items with the same label but they
> must belong to different boxes.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to