How to create a unique_for_field slug in Django?
问题 Django has a unique_for_date property you can set when adding a SlugField to your model. This causes the slug to be unique only for the Date of the field you specify: class Example(models.Model): title = models.CharField() slug = models.SlugField(unique_for_date='publish') publish = models.DateTimeField() What would be the best way to achieve the same kind of functionality for a non-DateTime field like a ForeignKey? Ideally, I want to do something like this: class Example(models.Model): title