On Jul 15, 3:13 pm, Arien <[EMAIL PROTECTED]> wrote:
> On Tue, Jul 15, 2008 at 7:34 AM, vicvicvic <[EMAIL PROTECTED]> wrote:
> > On Jul 15, 1:57 pm, Arien <[EMAIL PROTECTED]> wrote:
> >> On Tue, Jul 15, 2008 at 5:36 AM, vicvicvic <[EMAIL PROTECTED]> wrote:
>
> >> If a view picks a template and renders it using some data, the
> >> template is still free to present the data any way it likes (with some
> >> Content-Type related restrictions).  But you don't have to hard-wire
> >> the template (and the implicit Content-Type) in the view.  Write a
> >> view that has (optional) arguments (with sensible defaults) for the
> >> template (and the Content-Type).
>
> > Indeed I could do that, but I think my pattern is more general and
> > makes sure a view is ONLY responsible for describing what data you
> > see.
>
> That *is* its only responsibility.  But the view returns some kind of
> serialization of that data with some HTTP headers, not the data
> itself.  Don't read too much into the text from the FAQ.

While a view cannot (should not) know the contents of the template
used to serialize the content, loading a template named
"whatever.html" couples it to an HTML Content-type. I does not make
sense to serialize JSON data in a template named .html. I could of
course use templates named "whatever.serializing_template" and use

{% ifequal content_type "json" %}[1234,3452]{% else %}<p>1234</
p><p>3452</p>{% endif %}

in my template code but I think that looks butt-ugly. Also, how do I
set the Content-type-header in a Template?

> >> Django is a *Web* framework.  Views are the part of the framework that
> >> generate responses to requests and both of those necessarily use HTTP.
>
> > A response-request paradigm is hardly unique to HTTP. Yes, Django is a
> > web framework and yet, both models and templates are (naturally)
> > decoupled from HTTP. The documentation even includes a paragraph about
> > using templates in stand-alone mode!
>
> Sure, but that doesn't apply to views.

Why not?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to