Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13981

Creating a slug field from 2 different values in 2 different tables in Django

$
0
0

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

Viewing all articles
Browse latest Browse all 13981

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>