Re: Ajax-based generic views?

2009-07-22 Thread djangonoob

The following is replied by Vasil:
***
Very much depends on your application and how far down that rabbit
hole you want to go. Basically a good practice for a standard web app
would be not to have so much ajax to the extent that you'd want to use
django's generic CRUD views for ajax. There are so many web apps out
there with ajax in all the wrong places with degraded accessibility
and leaky security.

Most of the generic views that come with django were designed to
return content produced by rendering templates. The templates don't
have to be rendered to whole web pages, they can be just a form or a
div. You can post to a generic view with an ajax request and update
just a part of your page by returning just the html that's needed then
update the appropriate parts of your page. Templates can also be used
to return a JSON response. But I suggest you stay away from all that.

The best approach would be to use use django's generic views for most
of the stuff that uses "standard" post/get as much as you see fit and
write your own views for the ajax stuff. The generic views are just
views they are not rocket science. You can look at their code and
write ones designed to work with ajax in a couple of hours if you have
even a modest experience with django/python.

I strongly suggest you reexamine the need for so much ajax. If you
plan on making something like gmail or google docs you are better off
using pyjamas:
http://pyjs.org/
You can use it with django.

Btw you sent me a private email, it's better to post to django-users,
others might join in in a discussion and the messages are available to
the public.

On Thu, Jul 23, 2009 at 4:19 AM, djangonoob<ye.eug...@gmail.com>
wrote:
> i'm refering to making use of django's generic views to conduct CRUD
> operations,
> albeit with ajax effects such as inplace editing, ajax loading of data
> etc.
>
> Would it be easier to write our own CRUD with ajax? or can we make use
> of django's
> generic views?
>
> Best Regards.
>
> On Jul 23, 7:37 am, Vasil Vangelovski <vvangelov...@gmail.com> wrote:
>> What exactly do you mean by "ajax-based generic views"? Most often
>> you'd return a JSON response to an xhr request so instead of passing a
>> dict as a context object to render_to_response you'd return an HTTP
>> response with the dict serialized as JSON. Follow any guidelines for
>> making views generic, but instead of filling the response with a
>> template rendered as html return the content serialized as JSON.
>> Simplejson comes with django, Also you can serialize model objects
>> automaticallyhttp://docs.djangoproject.com/en/dev/topics/serialization/
>>
>> On Wed, Jul 22, 2009 at 11:36 PM, djangonoob<ye.eug...@gmail.com> wrote:
>>
>> > Hi all, i understand that this is a recurring topic.
>> > But i couldnt find any ajax-based generic views tutorials/threads,
>> > etc.
>>
>> > How do we implement ajax-based generic views?
>>
>> > BEst Rgds.

On Jul 23, 7:37 am, Vasil Vangelovski <vvangelov...@gmail.com> wrote:
> What exactly do you mean by "ajax-based generic views"? Most often
> you'd return a JSON response to an xhr request so instead of passing a
> dict as a context object to render_to_response you'd return an HTTP
> response with the dict serialized as JSON. Follow any guidelines for
> making views generic, but instead of filling the response with a
> template rendered as html return the content serialized as JSON.
> Simplejson comes with django, Also you can serialize model objects
> automaticallyhttp://docs.djangoproject.com/en/dev/topics/serialization/
>
> On Wed, Jul 22, 2009 at 11:36 PM, djangonoob<ye.eug...@gmail.com> wrote:
>
> > Hi all, i understand that this is a recurring topic.
> > But i couldnt find any ajax-based generic views tutorials/threads,
> > etc.
>
> > How do we implement ajax-based generic views?
>
> > BEst Rgds.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Ajax-based generic views?

2009-07-22 Thread Vasil Vangelovski

What exactly do you mean by "ajax-based generic views"? Most often
you'd return a JSON response to an xhr request so instead of passing a
dict as a context object to render_to_response you'd return an HTTP
response with the dict serialized as JSON. Follow any guidelines for
making views generic, but instead of filling the response with a
template rendered as html return the content serialized as JSON.
Simplejson comes with django, Also you can serialize model objects
automatically
http://docs.djangoproject.com/en/dev/topics/serialization/

On Wed, Jul 22, 2009 at 11:36 PM, djangonoob<ye.eug...@gmail.com> wrote:
>
> Hi all, i understand that this is a recurring topic.
> But i couldnt find any ajax-based generic views tutorials/threads,
> etc.
>
> How do we implement ajax-based generic views?
>
> BEst Rgds.
> >
>

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



Re: Ajax-based generic views?

2009-07-22 Thread mhulse

> How do we implement ajax-based generic views?

I am also a noob, but I personally would google:

django and jquery

Seems like Django is one beast to tackle, and Jquery is another.

Cheers,
M

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



Ajax-based generic views?

2009-07-22 Thread djangonoob

Hi all, i understand that this is a recurring topic.
But i couldnt find any ajax-based generic views tutorials/threads,
etc.

How do we implement ajax-based generic views?

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