List Info

Thread: Unique_togther - does it work.




Unique_togther - does it work.
user name
2006-11-23 16:46:25
 I am trying to ensure that a combination of two values must
be unique 
for a record.   I have the following code in my model, but
it is not 
working - am I missing something?


class Meta:
          unique_together = (("pack",
"code"),)
          pass


MerMer

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Unique_togther - does it work.
user name
2006-11-23 16:54:51
For the polls app I added a vote so I can limmit votes...

This is the model code and it is working fine.
Success.

class Vote(models.Model):
   poll = models.ForeignKey(Poll,
edit_inline=models.TABULAR,
num_in_admin=3)
   voter_ip = models.IPAddressField(core=True)
   choice = models.ForeignKey(Choice,
edit_inline=models.TABULAR,
num_in_admin=3)

   class Meta:
      unique_together = (("poll",
"voter_ip"),)

   def __str__(self):
      return self.voter_ip


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Unique_togther - does it work.
user name
2006-11-24 00:06:24
Rob,

I got it to work with other models.  However, it doesn't
seem to like
the fact that I am using an intemdiary table and that both
"pack" and
"code" have Foreign Keys.

MerMer


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )