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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.