Hello Pavel,
This is likely a bug because UniqueConstraint was only recently introduced.
Please file a bug report about it. In the mean time you can add this check to
your SILENCED_SYSTEM_CHECKS setting to silence it.
Best,
Simon
Hi all,I'm trying to create migration with uniqueness of 2 fields: uid, source.Django 2.2.9class Users(models.Model):
uid = models.CharField(...)
source = models.ForeignKey(...)
class Meta:constraints = [models.UniqueConstraint(fields =['uid', 'source'], name='users_uniqueness')]
indexes = [models.Index(fields=('uid', 'source'), name='users_indexes')]When I start makemigrations command in manage.py it rises fields.E310 errorapp_name.Users.field: (fields.E310) No subset of the fields 'uid', 'source' on model 'Users' is unique. HINT: Add unique=True on any of those fields or add at least a subset of them to a unique_together constraint.When I change Meta options to unique_together constraint it works ok. Migrations passes with no errors... class Meta:unique_together = [['uid', 'source']]As mentioned in docs unique_together may be deprecated in the future so I wanted to avoid this kind of issue.Thanks,Pavel
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b49b70d2-9a1d-409f-ac43-3a643a7f27b1%40googlegroups.com.
No comments:
Post a Comment