Opened 13 years ago
Closed 13 years ago
#17515 closed New feature (fixed)
custom templates in FilterSpec
Reported by: | Stefano Apostolico | Owned by: | Stefano Apostolico |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
django 1.4 allow an easier customization of FilterSpec but force all to the same presentation, should be useful customize the template used by the filter.
The patch simply allow to specify the template to use into FilterSpec or use the default one otherwise, moreover put the FilterSpec into the context to be available into temlplate
def admin_list_filter(cl, spec): if hasattr(spec, 'template') and spec.template: t = get_template(spec.template) else: t = get_template('admin/filter.html') ctx = Context({'title': spec.title, 'choices' : list(spec.choices(cl)), 'spec': spec}) return t.render(ctx)
Attachments (3)
Change History (11)
by , 13 years ago
Attachment: | filterspec_custom_templates.diff added |
---|
comment:1 by , 13 years ago
Needs documentation: | set |
---|---|
Needs tests: | set |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 13 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 13 years ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
by , 13 years ago
Attachment: | filterspec_custom_templates_0.1.diff added |
---|
patch with docs and tests also renamed template attribute as 'template_name'
comment:4 by , 13 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:5 by , 13 years ago
Patch needs improvement: | set |
---|
I think that 'template' would be better than 'template_name' and more consistent with other similar attributes in the admin (e.g. StackedInline.template
or ModelAdmin.change_form_template
). Also, a custom template file actually needs to be included in the patch.
by , 13 years ago
Attachment: | 17515.admin-filter-custom-templates.diff added |
---|
comment:6 by , 13 years ago
The latest patch uses 'template' instead of 'template_name', cleans up the implementation a bit and adds a custom template file to the tests.
comment:7 by , 13 years ago
Patch needs improvement: | unset |
---|