- Django 2 Web Development Cookbook
- Jake Kronika Aidas Bendoraitis
- 65字
- 2021-06-10 19:31:32
How to do it...
Open the models.py file of any Django app that you want to use mixins with, and type the following code:
# demo_app/models.py
from django.db import models
from django.utils.translation import ugettext_lazy as _
from utils.models import (CreationModificationDateMixin,
MetaTagsMixin,
UrlMixin)
class Idea(UrlMixin, CreationModificationDateMixin, MetaTagsMixin):
class Meta:
verbose_name = _("Idea")
verbose_name_plural = _("Ideas")
title = models.CharField(_("Title"), max_length=200)
content = models.TextField(_("Content"))
def __str__(self):
return self.title