> 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?