Skip to main content

Utility code and patterns.

Project description

Utility code and patterns. Tested against Python 2.7, 2.6 and Django 1.3, 1.4, 1.5, 1.6 (trunk).

Build Status Coverage Status PYPI Package

Terse admin.py

from django.contrib import admin
from admin_utils import register, inline

from .models import MyModel, OtherModel

@register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
    inlines = inline(OtherModel),

If you want custom admin sites:

customsite = admin.AdminSite()

@register(MyModel, site=customsite)
class MyModelAdmin(admin.ModelAdmin):
    inlines = inline(OherModel),

Mock admin (mount your views in admin using model wrappers)

Have you ever wanted a page in the admin that appears in the app list but you don’t have any models ? Now you can have that without patching up the admin Site or the templates. Just put this in your admin.py:

from django.conf.urls import patterns, url
from admin_utils import make_admin_class

make_admin_class("Test1", patterns("test_app.views",
    url(r'^$', 'root', name='test_app_test1_changelist'),
    url(r'^level1/$', 'level1', name='level-1'),
    url(r'^level1/level2/$', 'level2', name='level-2'),
), "test_app")

To use different admin site:

make_admin_class("Test1", patterns("test_app.views",
    url(r'^$', 'root', name='test_app_test1_changelist'),
    url(r'^level1/$', 'level1', name='level-1'),
    url(r'^level1/level2/$', 'level2', name='level-2'),
), "test_app", site=customsite)
Bitdeli badge

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-admin-utils-0.2.0.tar.gz (11.3 kB view details)

Uploaded Source

File details

Details for the file django-admin-utils-0.2.0.tar.gz.

File metadata

File hashes

Hashes for django-admin-utils-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1fdbe299c36426d8a80a80a092f31a0968e8d30f7115e37b20ab6438891048c8
MD5 2068c940d009da42989c32aa7eebcc06
BLAKE2b-256 5080c32c00f548d15167f1144233412b11c993189914375d33cecee94257a836

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page