django-genericadmin / genericadmin / admin.py

from django.db import models
from django.contrib import admin
from django.conf.urls.defaults import patterns, url
from genericadmin.views import generic_lookup

class Lookup(models.Model):
    """
    A `fake` model that gets registered so that we can create a custom admin
    url without having to override the default AdminSite.
    """
    pass

class GenericAdminModelAdmin(admin.ModelAdmin):
    model = Lookup

    def has_add_permission(self, request):
        return False

    def has_change_permission(self, request):
        return False

    def has_delete_permission(self, request):
        return False

    def get_urls(self):
        base_urls = super(GenericAdminModelAdmin, self).get_urls()
        custom_urls = patterns(
            '',
            url(r'^obj/$',
                self.admin_site.admin_view(generic_lookup),
                name='admin_genericadmin_obj_lookup'),
            )
        return custom_urls + base_urls

admin.site.register(Lookup, GenericAdminModelAdmin)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.