Reputation: 1887
I try to use django-uuslug, to manage unique and unicode slug with django. This project seems interesting, it is better to use an existing project to reinvent the wheel. However I have a question, I would to know if it's be possible to specify one column more, to make the slugify on the current object and the optionnal column. For example if we have a site column and want have slug unique per site not per table.
uuslug(self.title, instance=self, unique_per_column=self.site)
Otherwise is there a better way to manage slug in django or not.
Upvotes: 2
Views: 208
Reputation: 33833
If you have a look at the source code of uuslug, it is possible to do what you want like this:
uuslug(self.title, instance=self, filter_dict={'site': self.site})
this will cause uuslug to filter the queryset of instance
's model to rows with the same value of site
field before doing the uniqueness check on that queryset
Upvotes: 3