Let's say I want to use a different template for the add page but not the edit. What would be the best way to accomplish that? I was thinking either subclassing add_view or change_view, or alternatively maybe subclass some InlineModelAdmin method. What's your guys take on this? Thanks.
+1
A:
A good start might be to look at how it's done in django.contrib.auth.admin.UserAdmin
for example:
http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/admin.py
I would say subclassing add_view
is the way to go here.
Arnaud
2009-08-25 10:15:28
Thanks for the answer but the User Admin doesn't utilize any inlines.
orwellian
2009-08-25 18:11:18
A:
This is a pretty crappy solution but here is how I solved it:
class FooInline(admin.TabularInline):
model = Foo
def get_fieldsets(self, request, obj=None):
url = request.get_full_path()
if '/add/' not in url:
self.template = 'listing.html'
return super(FooInline, self).get_fieldsets( request, obj)
orwellian
2009-08-25 23:19:03