Thanks.

On Sat, Apr 4, 2009 at 11:26 AM, Daniel Roseman
<roseman.dan...@googlemail.com> wrote:
>
> On Apr 4, 2:06 pm, Chris <chriss...@gmail.com> wrote:
>> How would you enforce a unique column constraint on a combination of
>> fields?
>>
>> For example, say I have the model:
>>
>> class Company(models.Model):
>>     name = models.CharField(unique=True)
>>
>> class Article(models.Model):
>>     company = models.ForeignKey(Company)
>>     title = models.CharField(max_length=500)
>>
>> In the Article model, I'd want to make the combination of company
>> +title unique. In other words, one Company could be associated with
>> many Articles, and one Article title could be associated with many
>> Comanies, but no one company should be associated with the same
>> Article title more than once. Is that possible?
>
> http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together
> --
> DR.
> >
>

--~--~---------~--~----~------------~-------~--~----~
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