mirror of
https://github.com/django/django.git
synced 2025-07-03 17:29:12 +00:00
gis: Removed the sites
module and use the site
instance from django.contrib.admin
instead.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@8064 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
bfe714f014
commit
b33e709981
@ -1,5 +1,8 @@
|
||||
# Getting the normal admin routines, classes, and `site` instance.
|
||||
from django.contrib.admin import autodiscover, site, StackedInline, TabularInline, HORIZONTAL, VERTICAL
|
||||
|
||||
# Geographic admin options classes and widgets.
|
||||
from django.contrib.gis.admin.options import GeoModelAdmin
|
||||
from django.contrib.gis.admin.sites import GeoAdminSite, site
|
||||
from django.contrib.gis.admin.widgets import OpenLayersWidget
|
||||
|
||||
try:
|
||||
|
@ -1,37 +0,0 @@
|
||||
from django.contrib.admin import sites
|
||||
from django.contrib.gis.admin.options import GeoModelAdmin
|
||||
from django.db.models.loading import get_apps
|
||||
|
||||
class GeoAdminSite(sites.AdminSite):
|
||||
"""
|
||||
The GeoAdminSite is overloaded from the AdminSite to provide facilities
|
||||
for editing geographic fields (using the GeoModelAdmin for the options
|
||||
class instead of ModelAdmin).
|
||||
"""
|
||||
def register(self, model_or_iterable, admin_class=None, **options):
|
||||
"Overloaded register method that uses GeoModelAdmin."
|
||||
admin_class = admin_class or GeoModelAdmin
|
||||
try:
|
||||
return super(GeoAdminSite, self).register(model_or_iterable, admin_class, **options)
|
||||
except sites.AlreadyRegistered:
|
||||
# Unlike the default behavior in newforms-admin we won't
|
||||
# raise this exception.
|
||||
pass
|
||||
|
||||
# `site` is an instance of GeoAdminSite
|
||||
site = GeoAdminSite()
|
||||
|
||||
# Re-registering models that appear normally in AdminSite with the
|
||||
# GeoAdminSite (if the user has these installed).
|
||||
APPS = get_apps()
|
||||
|
||||
# Registering the `auth` Group & User models.
|
||||
from django.contrib.auth import models, admin
|
||||
if models in APPS:
|
||||
site.register(models.Group, admin.GroupAdmin)
|
||||
site.register(models.User, admin.UserAdmin)
|
||||
|
||||
# Registering the `sites` Site model.
|
||||
from django.contrib.sites import models, admin
|
||||
if models in APPS:
|
||||
site.register(models.Site, admin.SiteAdmin)
|
Loading…
x
Reference in New Issue
Block a user