I've checked this but i need to concatenate contents in two fields okay, here's the question.
I have two models, brand
and product
which looks something like this:
Brand Model
class Brand(models.Model):
name = models.CharField(max_length=29)
website = models.URLField()
def __unicode__(self):
return self.name
Product Model
class Product(models.Model):
brand = models.ForeignKey(Brand)
name = models.CharField(max_length=140)
slug = models.SlugField()
def __unicode__(self):
return self.name
Admin methods
from .models import Product
@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('name',)}
Sample inputs on models:
**Brand**
Name: Example
Website: http://www.example.com
**Product**
Brand: Example (Selection)
Name: Product
Slug: product(prepopulated)
I want the slug to be example-product
than product
. How can I concatenate both the brand and name as the slug.
Thank you for any help.