dingo 0.2.2

Django Admin Extender

  Add it to your Download Basket!

 Add it to your Watch List!

0/5

Rate it!
send us
an update
LICENSE TYPE:
BSD License 
USER RATING:
UNRATED
  0.0/5
DEVELOPED BY:
Nathan R. Yergler
HOMEPAGE:
gitorious.org
CATEGORY:
ROOT \ Internet \ HTTP (WWW)
dingo is a Django app which extends the Django Admin to allow the easy creation of additional views for Model classes and instances. dingo also allows you to customize the Admin of third party applications, without subclassing or modifying the original source tree.

Usage

To use dingo, ensure that it's on the Python path, and add it to your INSTALLED_APPS setting in settings.py. Note that dingo must be installed before django.contrib.admin, as it replaces the default AdminSite with one which will instrument the ModelAdmin classes registered.

Models vs. Objects

dingo can be used to register views for Models or Objects. Views registered for Models are not specific to any instance of the model; they can be thought of as similar to Django admin actions with an [potentially] empty queryset. Instance views operate on single model instances; you can think of them as similar to admin actions that operate on a single object instead of a queryset.

dingo views differ from admin actions in a couple of subtle ways. The most important difference is that they may be injected into third party applications wihthout sub-classing or modifying the application code. dingo views also have a different user interface by default. dingo includes replacement admin templates which show dingo views as buttons in the upper right hand area of the change list and change form views.

Adding Views

If you want to use dingo to add model or object views to your Model's admin, you can define them either as functions or as methods on the ModelAdmin.

For example, to define the view as a function:

import dingo
import dingo_test.models

@dingo.object_view(dingo_test.models.RstDocument)
@dingo.short_description("Render")
def render(model_admin, request, object_id):

 from django.shortcuts import redirect
 document = dingo_test.mdoels.RstDocument.objects.get(id=object_id)

 return Response()

The same view may also be a method on the ModelAdmin:

class RstDocumentAdmin(ModelAdmin):

 @dingo.object_view(dingo_test.models.RstDocument)
 @dingo.short_description("Render")
 def render(self, request, object_id):
 pass


Note that the use of the short_description decorator defines the label used in the admin user interface, and is optional in this case. If no description is provided, dingo will format the function or method name, similar to how Django formats default verbose names for models.

Adding Views to Third Party Applications

So long as dingo is listed in INSTALLED_APPS before django.contrib.admin, the function-based example above will work as desired. Note that the code needs to be imported to ensure that registration occurs properly.

Last updated on January 31st, 2011

feature list requirements

#Django Admin #Model classes #Model instances #Django #admin #views #model

Add your review!

SUBMIT