Opened 17 years ago

Closed 14 years ago

#5392 closed (fixed)

[newforms-admin] - hooks for template names

Reported by: Petr Marhoun <petr.marhoun@…> Owned by: nobody
Component: contrib.admin Version: newforms-admin
Severity: Keywords: nfa-someday
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

I think it is possible to have more admin sites in one project. And it would be nice to have different default templates for these two sites - these templates should be independent on application.

So I would like to have some hooks as changelist_templates, add_templates and so on. For example this code could be changed:

class ModelAdmin(BaseModelAdmin):

    def changelist_view(self, request):
        ### ...
        return render_to_response(['admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()),
                                'admin/%s/change_list.html' % app_label,
                                'admin/change_list.html'], context_instance=c)

New variant:

class ModelAdmin(BaseModelAdmin):

    def changelist_view(self, request):
        ### ...
        return render_to_response(self.changelist_templates(app_label, opts.object_name.lower()), context_instance=c)

    def changelist_templates(self, app_label, object_label):
        return ['admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()),
            'admin/%s/change_list.html' % app_label,
            'admin/change_list.html']


I haven't need it yet so I have no patch. But it is no problem for me to create it - if you think it is a good idea.

Attachments (2)

04-admin-template-names.diff (7.9 KB ) - added by Petr Marhoun <petr.marhoun@…> 16 years ago.
02-admin-template-names.diff (8.0 KB ) - added by Petr Marhoun <petr.marhoun@…> 16 years ago.
new version depends on #6002 and on #6010 - they change the same places

Download all attachments as: .zip

Change History (7)

comment:1 by Petr Marhoun <petr.marhoun@…>, 17 years ago

Why is the function render_change_form in views/main.py? I think it could be a method of ModelAdmin. This move would be usefull for this ticket.

> grep render_change_form django/contrib/admin/** --line-number 
django/contrib/admin/options.py:411:        from django.contrib.admin.views.main import render_change_form
django/contrib/admin/options.py:462:        return render_change_form(self, model, model.AddManipulator(), c, add=True)
django/contrib/admin/options.py:466:        from django.contrib.admin.views.main import render_change_form
django/contrib/admin/options.py:540:        return render_change_form(self, model, model.ChangeManipulator(object_id), c, change=True)
django/contrib/admin/views/main.py:113:def render_change_form(model_admin, model, manipulator, context, add=False, change=False, form_url=''):

comment:2 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedDesign decision needed

by Petr Marhoun <petr.marhoun@…>, 16 years ago

comment:3 by Petr Marhoun <petr.marhoun@…>, 16 years ago

I am sorry, my patch depends on some other patches - it is for simple merging. So my patch can't be applied without problem. But I would like to prepare proper patch, if it would be accepted.

comment:4 by Brian Rosner, 16 years ago

Keywords: nfa-someday added; newforms admin templates removed
Patch needs improvement: set

This functionality is not critical before the merge to trunk. Tagging with nfa-someday.

by Petr Marhoun <petr.marhoun@…>, 16 years ago

new version depends on #6002 and on #6010 - they change the same places

comment:5 by Malcolm Tredinnick, 14 years ago

Resolution: fixed
Status: newclosed

This is now possible to you things like ModelAdmin.change_list_template in the current admin.

Note: See TracTickets for help on using tickets.
Back to Top