I'm trying to create a slug field in django that requires the use of 2 table fields from 2 different tables.
What is the best way of going about this?
For example:If I had a Restaurant table with a restaurant_name
field and a Location table with a location_name
field, how do I create a slug field from these two values? That is, a slugfield generated from restaurant_name + location_name
EDIT:
If possible, I would like to use AutoSlug Field in the solution. For example here is an implementation with a single field to slugify:
class Cuisine(models.Model): name = models.CharField(max_length=100) name_slug = AutoSlugField(populate_from='name', unique=True, null=True) def __str__(self): return self.name