Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. # Django UniqueConstraint {{tag>Django UniqueConstraint}} unique_togther 대신에 UniqueConstraint 사용 <code del> ## DO NOT USE unique_together class Meta: unique_together = ('brand', 'parent', 'name',) </code> <code> from django.db import models from brand.models import BaseModel class Category(BaseModel): parent = models.ForeignKey("self", on_delete=models.CASCADE, null=True) name = models.TextField(db_index=True) product_count = models.IntegerField(default=0) like_count = models.IntegerField(default=0) level = models.IntegerField(null=True) class Meta: constraints = [ models.UniqueConstraint(fields=["parent", "name"], name="unique name") ] </code> open/django-uniqueconstraint.txt Last modified: 2024/10/05 06:15by 127.0.0.1