ALJ
unread,Mar 12, 2012, 7:50:18 AM3/12/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
I'm struggling to get my models to enforce unique_together. We have the model below where it is possible to have a budget for a whole group (ie there is no break down for a particular sales rep) and therefore the sales_rep field will be left empty. However, it it possible to enter two identical values into the database via the Admin interface where the budget and years are the same while the sales_rep is empty.
I have seen some discussion on it in the archives, but wondered if there is a work around.
Cheers
ALJ
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
class Budget(models.Model):
budget_type = models.ForeignKey(BudgetType, blank=False)
sales_rep = models.ForeignKey(SalesRep, null=True, blank=True)
year = models.IntegerField(blank=False)
amount = models.FloatField(blank=False)
class Meta:
unique_together = (("budget_type","sales_rep", "year"),)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>