Playing with the admin system

The built-in admin application is enabled by default in new Django projects. Before we can use it, however, we need to register the various database models we want it to support. To do this, edit the admin.py module within the shapeEditor/shared directory, and enter the following into this file:

from django.contrib.gis import admin
from shapeEditor.shared.models import *

admin.site.register(Shapefile, admin.ModelAdmin)
admin.site.register(Feature, admin.GeoModelAdmin)
admin.site.register(Attribute, admin.ModelAdmin)
admin.site.register(AttributeValue, admin.ModelAdmin)

The ModelAdmin class tells Django how to display the model within the admin interface. Notice that we use the GeoModelAdmin class for the Feature class. ...

Get Python Geospatial Development - 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.