سؤال

I'm try to set a unique_together condition based on a specific value: something like:

class Meta:
   unique_together = (user, somefield=True)

Is this possible? Is there a model method I should override? if so how?

Thanks!

هل كانت مفيدة؟

المحلول

unique_together just tells Django to create unique index for the given fields. Uniqueness is checked by the database not by Django. So simple answer is NO, but if you tell more about your model there could be a good way to organize your data...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top