Opened 19 years ago

Closed 16 years ago

#541 closed enhancement (fixed)

[patch] Making generic views use other templates like Zope3 ZPT

Reported by: jpaulofarias@… Owned by: Jacob
Component: Generic views Version: 1.0
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by Jacob)

Hi!

I was wondering if it is possible to use other template engines with generic views.

I think making template_loader a parameter of object_list at file list_detail.py, with default value django.core.template_loader should make it flexible enough to use any template engine.

The user could, then, switch to zope3 zpt by adding a key on the dict of the url patterns parameter, like this:

from django.contrib.pagetemplate import pagetemplate

info_dict = {
  'app_label': 'myapp',
  'app_module': 'mymodule',
  'template_loader': pagetemplate,
}

Hope this will be helpful.

--
João Paulo Fernandes Farias

Attachments (1)

template_loader_for_direct_to_template.patch (1005 bytes ) - added by burp_ 16 years ago.
template_loader argument for direct_to_template in simple.py

Download all attachments as: .zip

Change History (11)

comment:1 by Jacob, 19 years ago

Description: modified (diff)
Status: newassigned

Sounds like a great idea. I'll add this when I get a moment, but if you want to write a patch that will make it happen quicker.

comment:2 by jpaulofarias@…, 19 years ago

Patch bellow!

Index: django/views/generic/list_detail.py
===================================================================
--- django/views/generic/list_detail.py (revisão 661)
+++ django/views/generic/list_detail.py (cópia de trabalho)
@@ -7,7 +7,8 @@
 from django.core.exceptions import Http404, ObjectDoesNotExist

 def object_list(request, app_label, module_name, paginate_by=None, allow_empty=False,
-                template_name=None, extra_lookup_kwargs={}, extra_context={}):
+                template_name=None, template_loader=template_loader,
+                extra_lookup_kwargs={}, extra_context={}):
     """
     Generic list of objects.

@@ -76,7 +77,8 @@

 def object_detail(request, app_label, module_name, object_id=None, slug=None,
                   slug_field=None, template_name=None, template_name_field=None,
-                  extra_lookup_kwargs={}, extra_context={}):
+                  template_loader=template_loader, extra_lookup_kwargs={},
+                  extra_context={}):
     """
     Generic list of objects.

comment:3 by Jacob, 19 years ago

milestone: Version 1.0
Summary: Making generic views use other templates like Zope3 ZPT[patch] Making generic views use other templates like Zope3 ZPT

comment:4 by Jacob, 19 years ago

Resolution: fixed
Status: assignedclosed

(In [734]) Fixed #541 - generic views now may take a template_loader argument so they can use a different template loader than Django's own. Thanks, Joao.

comment:5 by (none), 17 years ago

milestone: Version 1.0

Milestone Version 1.0 deleted

comment:6 by burp_, 16 years ago

Needs tests: set
Patch needs improvement: set
Resolution: fixed
Status: closedreopened
Version: 1.0

Since the integration of simple.py in revision @1247 jacob did not include the template_loader argument in direct_to_template. This dead simple patch does it ;)

by burp_, 16 years ago

template_loader argument for direct_to_template in simple.py

comment:7 by burp_, 16 years ago

PS: It would be nice to have this also in django.contrib.auth.views: http://code.djangoproject.com/ticket/4247

In my case I could reuse these view functions and use my own template system. Otherwise I'd just to copy these views functions over and replace the render_to_response things with my own one.

comment:8 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: reopenedclosed

Please open a new ticket for new feature requests. This ticket was already fixed ages ago and you're essentially asking for a new feature. That way we can keep the history of this ticket clean and decide independently if we want to add the new feature or not.

comment:9 by burp_, 16 years ago

Resolution: fixed
Status: closedreopened

I was asking for a "feature" in my PS, but not before (I made 3 posts/changes in total). The change before asks for consistency in generic views.

Just as the template_loader argument is in _all_ other generic views, it should also be in direct_to_template. It's clear why it hasn't this feature. In revision 743 when this extra argument was introduced direct_to_template did not exist, and later when direct_to_template was added in revision 1247 jacob simply forgot to make it consistent with the other generic views.

comment:10 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: reopenedclosed

Once again, this particular ticket was closed over three years ago. If something has changed since then, please open a new ticket so that we can track it appropriately. If we decide to "wontfix" your particular changes, for example, it would currently require setting "wontfix" on a ticket that has already been marked as fixed.

Please do not reopen this one.

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