Using Django without templates?

140 views
Skip to first unread message

ApathyBear

unread,
Feb 26, 2014, 5:46:39 PM2/26/14
to django...@googlegroups.com
I was briefly talking with a developer from Google whom I had met. 

He mentioned something that I hadn't really gotten a chance to ask him more about

He told me to be careful with django templates because in terms of scale, they can cause problems and almost always need to be re-written. Rather he mentioned something like using a 'full stack'.

I think back, and I don't exactly follow what he means by that. Is their a way to use Django without templates? Is it better ? Why or why not?

Camilo Torres

unread,
Feb 27, 2014, 8:48:21 PM2/27/14
to django...@googlegroups.com
On Wednesday, February 26, 2014 6:16:39 PM UTC-4:30, ApathyBear wrote:
He mentioned something that I hadn't really gotten a chance to ask him more about
He told me to be careful with django templates because in terms of scale, they can cause problems and almost always need to be re-written. Rather he mentioned something like using a 'full stack'.
I think back, and I don't exactly follow what he means by that. Is their a way to use Django without templates? Is it better ? Why or why not?
Hello,

A web application is based on the HTTP protocol, that is text based. The purpose of the protocol is that a web browser request a document, and the server responds with a document text (may be other kind of content types, like images). Django manages this protocol through the use of views and url configurations: each url is managed by a view. The view responsibility is to deliver a (text) document, and do so via a django.http.response.HttpResponse object. So you only need to return, in your views, HttpResponse objects.

You can simply return in every view something like this:
return HttpResponse('hello world')

and it will work, without using templates. This is faster than loading a template with the text 'hello world', render and pass it to the view.

You can do that to return complex HTML (or other types of) documents of your site. Or you can use a template system and manage the HTML more easily with a bit more processing overhead. You can use other template systems besides the provided by Django, like Jinja (that has shown to be faster in some benchmarks compared to Django's).

Regards,
Camilo

Mario Gudelj

unread,
Feb 27, 2014, 9:37:45 PM2/27/14
to django...@googlegroups.com

You do have to be careful with templates if you're using too many inclusions or if you have too much logic in them. There's a good django debug toolbar add-on that informs you about the time a template takes to compile.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2aa3d77a-da31-460e-b472-204e2548b69a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

bobhaugen

unread,
Feb 28, 2014, 10:14:18 AM2/28/14
to django...@googlegroups.com
On Thursday, February 27, 2014 8:37:45 PM UTC-6, somecallitblues wrote:

You do have to be careful with templates if you're using too many inclusions or if you have too much logic in them. There's a good django debug toolbar add-on that informs you about the time a template takes to compile.


I'm currently having performance problems with templates that have many small django forms in them.  Plan to try something like Angular.js instead of django templates and see if it's better.

The reference to "full stack" ~might~ have meant something like Meteor, a framework that uses javascript on both server and client.
Reply all
Reply to author
Forward
0 new messages