March 2020
Intermediate to advanced
608 pages
17h 17m
English
Follow these steps to complete the recipe:
# myproject/apps/ideas/models.pyfrom django.db import modelsfrom django.utils.translation import gettext_lazy as _from myproject.apps.core.models import ( CreationModificationDateBase, UrlBase )class Idea(CreationModificationDateBase, UrlBase): # attributes, fields, properties, and methods… @property def structured_data(self): from django.utils.translation import get_language lang_code = get_language() data = { "@type": "CreativeWork", "name": self.translated_title, "description": self.translated_content, "inLanguage": lang_code, } if self.author: data["author"] = { "@type": "Person", "name": self.author.get_full_name() ...