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. Because the Feature
object includes geometry fields, using the GeoModelAdmin
class allows the admin interface to edit these geometry fields using a slippy map. We'll see how this works shortly.
Now that the admin
module has been configured, let...