im want to know if there is any way to make a Slug开发者_C百科Field unique for Any field different to pub date?
for example i would like a slug unique (city field) for a field called country
any idea?
thanks
Add a unique_together
Meta option to your model class:
class MyModel(models.Model):
city = models.SlugField()
country = models.SlugField()
class Meta:
unique_together(('city', 'country'),)
For more information, see the documentation on unique_together
.
精彩评论