class SeoModel(models.Model):
seo_title = models.CharField('Title', blank=True, max_length=250)
seo_description = models.CharField('Description', blank=True, max_length=250)
seo_keywords = models.CharField('Keywords', blank=True, max_length=250)
def get_seo_title(self):
if self.seo_title:
return self.seo_title
return ''
def get_seo_description(self):
if self.seo_description:
return self.seo_description
return ''
def get_seo_keywords(self):
if self.seo_keywords:
return self.seo_keywords
return ''
class Meta:
abstract = True
class Product(SeoModel):
поля для этой модели
{% block seo %}
<title>{{ product.get_seo_title }} {{ usersettings.seo_title }}</title>
<meta name="description" content="{{ product.get_seo_description }}"/>
<meta name="keywords" content="{{ product.get_seo_keywords }}"/>
{% endblock %}