How to do it...

The administration of the Location model is as simple as it can be. Perform the following steps:

  1. Let's create the administration settings for the Location model. Note that we are using the get_fieldsets() method to define the field sets, with a description rendered from a template, as follows:
# locations/admin.py
from django.contrib import adminfrom django.template.loader import render_to_stringfrom django.utils.translation import ugettext_lazy as _from .models import Locationclass LocationAdmin(admin.ModelAdmin):    save_on_top = True    list_display = ("title", "street", "description")    search_fields = ("title", "street", "description")    def get_fieldsets(self, request, obj=None): map_html = render_to_string("admin/includes/map.html") ...

Get Django 2 Web Development Cookbook - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.