Django and Ajax

6 views
Skip to first unread message

Ahik Man

unread,
Aug 29, 2008, 4:08:04 AM8/29/08
to pywe...@googlegroups.com
Hi All,

Anybody has an experience with Django and Ajax? It could be by using JS directly or by some lib like Dojo or JQuery.
We are looking for presentation on this subject at the coming meeting.

Please, do not hesitate to response with any relevant comment.

Ahik

Udi h Bauman

unread,
Aug 29, 2008, 5:12:05 AM8/29/08
to pywe...@googlegroups.com
Hi Ahik,

We've been using Django & AJAX many times. We did it quite straight forward & lightweight:
  • The simplest common case which we use a lot is an asynchronous JavaScript call to a service, usually to perform some operation, without loading the full page. The Django service can also very easily return JSON code (using the Django serializers), which can be used in the client. For that we used the simple prototype JavaScript library, which only requires to be imported in the template & can be used in 1-2 lines of code.
  • To implement the interactive rich UI, which usually goes with AJAX, we chose Ext, which does this job well: doesn't require much knowledge or coding to add rich UI components & use them in your views. Note that it has dual (GPL/Commercial) licensing, so it may not suite you. There are also people criticizing Ext, in relation to its being a commercial spin of of open source code by Yahoo, but we've just wanted something simple & powerful that just works. There are of course alternatives with non-restrictive licensing, such as the ones you mentioned (Dojo & JQuery) & also YUI & Echo2. Prior to Ext we've also used other powerful frameworks, also commercial in nature, such as Bindows & Tibco, which also offer a free AJAX-based IDE.
As a general note, the JavaScript offerings are becoming even more powerful these days, e.g., with new HTML features enabling amazing visualizations, compilation to native code which will be available in FireFox 3.1, or browser extensions enabling simple user mashups.

Hope this helps.

Udi

Meir Kriheli

unread,
Aug 29, 2008, 7:50:45 AM8/29/08
to pywe...@googlegroups.com

I'm using Django with mootools combined with django's serializers -
works great (played with jquery as well).


Cheers
--
Meir Kriheli
me...@mksoft.co.il

Meir Kriheli

unread,
Aug 29, 2008, 7:53:49 AM8/29/08
to pywe...@googlegroups.com
Udi h Bauman wrote:
> Hi Ahik,
>
> We've been using Django & AJAX many times. We did it quite straight
> forward & lightweight:
>
> * The simplest common case which we use a lot is an asynchronous

> JavaScript call to a service, usually to perform some operation,
> without loading the full page. The Django service can also very
> easily return JSON code (using the Django serializers), which can
> be used in the client. For that we used the simple prototype
> <http://www.prototypejs.org/> JavaScript library, which only

> requires to be imported in the template & can be used in 1-2 lines
> of code.
> * To implement the interactive rich UI, which usually goes with
> AJAX, we chose Ext <http://extjs.com/>, which does this job well:

> doesn't require much knowledge or coding to add rich UI components
> & use them in your views. Note that it has dual (GPL/Commercial)
> licensing, so it may not suite you. There are also people
> criticizing <http://pablotron.org/?cid=1556> Ext, in relation to

> its being a commercial spin of of open source code by Yahoo, but
> we've just wanted something simple & powerful that just works.
> There are of course alternatives with non-restrictive licensing,
> such as the ones you mentioned (Dojo & JQuery) & also YUI & Echo2.
> Prior to Ext we've also used other powerful frameworks, also
> commercial in nature, such as Bindows & Tibco, which also offer a
> free AJAX-based IDE.
>
<---snipped--->

I had problems with Ext's actions in the past. Wrote about it @whatsup:

http://whatsup.org.il/article/6055

Cheers
--
Meir kriheli

daonb

unread,
Aug 30, 2008, 11:32:58 AM8/30/08
to PyWeb-IL
> Hi All,
>
> Anybody has an experience with Django and Ajax? It could be by using JS
> directly or by some lib like Dojo or JQuery.
> We are looking for presentation on this subject at the coming meeting.

I've been playing with Django and JSON and it's pretty easy. I added a
JSON property to each of my models, returning its JSON form:

class Book(models.Model):
...
@property
def JSON(self):
return simplejson.dumps ({'url': self.get_url(),
'cover': { 'title': self.title,
'author': self.author_name,
'illustrator': self.illustrator,
'back_cover': self.back_cover,
'owner_id': self.owner.id,
},
'pages': self.pages,
}, ensure_ascii=False)

I than add in the template:

<script type="text/javascript">
{% autoescape off %}
book = {{ book.json }}
{% autoescape on %}
</script>

Than I can play around with javascript to do all kind of stuff, like
paging. I'm using prototype but I'm thinking of switching to jQuery -
be great if someone can show an example with that (I think the Django
side is probably the same).
The PUT requests for updating the models are a bit more challenging.
For that I have an ajax.py file with the views needed to update the
book.
How about we lay off the powerpoint, and share demo apps? We can keep
it short - demonstrated in 5 minutes or less - and use our time for
discussion?

Ahik Man

unread,
Aug 31, 2008, 1:59:30 AM8/31/08
to pywe...@googlegroups.com
Thanks guys, for all the response.

Let's go for Benny's suggestion, anyone who can share some Django/Ajax stuff, please send me a presentation idea. Please include the following:

title
description
required time (5 minutes, 15 minutes or more)


Thanks
Ahik

Ahik Man

unread,
Aug 31, 2008, 4:41:55 AM8/31/08
to pywe...@googlegroups.com
Hi Udi.

Are you coming to the next meeting? It will be at Google-Israel.

We are plan to have 'Django & Ajax' slot. Can you make a presentation?

Ahik

Udi h Bauman

unread,
Aug 31, 2008, 6:15:01 AM8/31/08
to pywe...@googlegroups.com
Hi,

I'll be happy to come & share my experience in a short presentation. I'm trying to get Alex Arshavski to come as well, & show us some of the things he did with Django+AJAX.


Thanks for organizing!
Udi

Ahik Man

unread,
Aug 31, 2008, 6:50:09 AM8/31/08
to pywe...@googlegroups.com
Very good.
So, the title can be: "Django and Ajax - real examples" by you and Alex.

Is it OK?

Ahik

taleinat

unread,
Aug 31, 2008, 7:07:18 AM8/31/08
to PyWeb-IL
I've been working with Django+AJAX+jQuery for the past 6 months, with
great results. However, I won't be able to show any examples of my
work yet.

I would definitely like to come to the meeting though!

Thanks for organizing this,
- Tal
Reply all
Reply to author
Forward
0 new messages