开发者

Slug unique for another field different to the pub date?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜