tlovett1
tlovett1

Reputation: 1099

Creating a custom admin view

I want to want show reports in the admin based on a number of models. No data will be managed in this view. This view will merely show data in a different way. Therefore, admin.site.register(Model, ModelAdmin) doesn't really make sense. I keep reading about this: https://docs.djangoproject.com/en/1.2/ref/contrib/admin/#adding-views-to-admin-sites

Unfortunately, I don't really know where to start with that. Can anyone explain how to do this with code examples? Thanks!

Upvotes: 2

Views: 92

Answers (1)

drabo2005
drabo2005

Reputation: 1096

Use django admin.StackedInline, by displaying only the data , if i understand your request. one example

admin.py 

from project.app.models import  model1
class classInline(admin.StackedInline):
    model = model1
    extra = 0

class myclassAdmin(admin.ModelAdmin):
       list_display =('attribute1','attribute2','attribute3') # display model1 attributes
       inlines=[classInline,] 

admin.site.register(model1,myclassAdmin)

Upvotes: 2

Related Questions