template logic vs AJAX newbie seeks advice

63 views
Skip to first unread message

Sells, Fred

unread,
May 4, 2012, 9:17:35 AM5/4/12
to django...@googlegroups.com

Up to now, I’ve been using Flex for my client side and having Django return xml for the last 2 years.  With Adobe’s policy changes regarding Flex support, I need to shift future efforts to HTML5.  I’m seeking some general advice from the group on basic technology/techniques.  My specific question is…

 

When looking at the Django templating features vs using a tool like CS5.5  or expression blend,  what advice would you offer deciding how much to put into the template logic and how much to do via AJAX/Javascript/Jquery?   My applications are generally 10 to 30 pages and I have a 10% commonality between applications. 

 

Finally we are a small shop and I’m the only developer doing this  and I’m concerned about how well I can master the templating syntax.

Bill Freeman

unread,
May 4, 2012, 9:35:44 AM5/4/12
to django...@googlegroups.com
And the last shall be first: The template language is easy. The
stumbling block I have most often seen is people expecting to be able
to program in it, rather than the proper approach of moving anything
complicated into python code (in the form of model instance methods or
custom tags and filters, or suitable pre-calculation in the view
function).

As to where the functionality goes, that depends on your application.
Things that need to be responsive and shiny, especially if they don't
need information not already loaded, or to change the back end
database, probably deserve to be in the browser. Even minor amounts
of additional data load or saving can be done over AJAX, though,
obviously, the AJAX has to be connected to a view on the Django side.
Somewhat tricker is how to deal with visitors using browsers which
don't support HTML5 (thank goodness that IE6 is finally starting to
ebb), or curmudgeons like me who have to be persuaded to unblock
JavaScript for your site.

Bill

Reinout van Rees

unread,
May 4, 2012, 10:34:45 AM5/4/12
to django...@googlegroups.com
On 04-05-12 15:17, Sells, Fred wrote:
> Up to now, I�ve been using Flex for my client side and having Django
> return xml for the last 2 years. With Adobe�s policy changes regarding
> Flex support, I need to shift future efforts to HTML5. I�m seeking some
> general advice from the group on basic technology/techniques. My
> specific question is�

Swapping xml output from Django for JSON output should be pretty
straightforward, I guess. And you can feed the JSON to your brand new
html5+javascript front-end. If you're comfortable with javascript, this
could be pretty similar in nature to your current setup.

> When looking at the Django templating features vs using a tool like
> CS5.5 or expression blend, what advice would you offer deciding how much
> to put into the template logic and how much to do via
> AJAX/Javascript/Jquery? My applications are generally 10 to 30 pages and
> I have a 10% commonality between applications.

I blogged about the ajax/template split regarding Django a couple of
days ago and got some helpful comments. Perhaps some of them give you
some additional feel for the matter:

http://reinout.vanrees.org/weblog/2012/04/30/django-vs-ajax-how-far.html



Reinout

--
Reinout van Rees http://reinout.vanrees.org/
rei...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"

Etienne B. Roesch

unread,
May 4, 2012, 1:15:24 PM5/4/12
to django...@googlegroups.com
Thanks for the link to your post Reinout!

So, have you made a decision about the way to go for your application?


I like the idea of using two different systems from the backend and the frontend. I am new to django (a month+), but I don't think there was ever a doubt in mind that my frontend would be .js based, and I liked that django dev let /static to be dealt with by say plain Apache, instead of enforcing python for that too.

As I said, I am new to django, but I have done some experiments (wrote my own little hello world app, moved on to deploying mezzanine to dotcloud), and as I understand django is meant to be a flexible system to handle data, and was never meant to be a flexible frontend, right?

Now, even though I do like the proper tools for the proper jobs, the perspective of maintaining two systems built on different technologies raises red flags. What do people think?

Kind regards,

Etienne

Reinout van Rees

unread,
May 5, 2012, 3:07:55 PM5/5/12
to django...@googlegroups.com
On 04-05-12 19:15, Etienne B. Roesch wrote:
> Thanks for the link to your post Reinout!
>
> So, have you made a decision about the way to go for your application?

For the near future we're sticking with templates, but with javascript
for the spots where we need it (we'll use backbone to clean up on part
of the UI).

> I like the idea of using two different systems from the backend and the
> frontend. I am new to django (a month+), but I don't think there was
> ever a doubt in mind that my frontend would be .js based, and I liked
> that django dev let /static to be dealt with by say plain Apache,
> instead of enforcing python for that too.

And... with django's staticfiles handling you can even bundle
js/css/images per app and Django'll combine it all together. Works great.

> As I said, I am new to django, but I have done some experiments (wrote
> my own little hello world app, moved on to deploying mezzanine to
> dotcloud), and as I understand django is meant to be a flexible system
> to handle data, and was never meant to be a flexible frontend, right?

Django has always been frontend-agnostic. There's only the admin
interface, for the rest you have to build everything yourself.

> Now, even though I do like the proper tools for the proper jobs, the
> perspective of maintaining two systems built on different technologies
> raises red flags. What do people think?

Well, if the separation is clean enough, it is fine. Just make sure you
don't tie them together too much.

M Hussain

unread,
May 5, 2012, 4:34:26 PM5/5/12
to django...@googlegroups.com
I think I'm in the same situation of considering Django for developing a webapp or knowing Django features to develop UI. Is that possible to develop UI like a desktop application, features like, tab, Buttons, Checkboxes, lists, ploting graphs based on the data read from DB.

Please do suggest in this regard. Sorry, may be my post is irrelevant to this thread in perticular.

Cheers
Hussain



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


Reinout van Rees

unread,
May 5, 2012, 6:35:35 PM5/5/12
to django...@googlegroups.com
On 05-05-12 22:34, M Hussain wrote:
> I think I'm in the same situation of considering Django for developing a
> webapp or knowing Django features to develop UI. Is that possible to
> develop UI like a desktop application, features like, tab, Buttons,
> Checkboxes, lists, ploting graphs based on the data read from DB.

Well, if you want the full desktop-like experience in a web page, you
ought to look at extjs: http://www.sencha.com/products/extjs/

Full windows-like buttons, tabs, etc stuff.

It won't be usable on a mobile phone, but if a heavy js interface (it
*is* quite big) is no problem: take a look.
Reply all
Reply to author
Forward
0 new messages