Ajax replacement in django

93 views
Skip to first unread message

lankesh87

unread,
Oct 12, 2011, 10:17:58 AM10/12/11
to Django users
Hello,
I am developing a web application where i need ajax like features.
But I don't want to use ajax, so my question is- "is there any way to
perform ajax like functions in django?"

Javier Guerra Giraldez

unread,
Oct 12, 2011, 10:24:21 AM10/12/11
to django...@googlegroups.com

that kind of specifications (ajax-like but no ajax) sound very weird
to me. I find only two explanations:

A) you don't know how HTTP works

or

B) when you say 'ajax' you're in fact talking about a specific library
that you don't want to use and not the generic javascript-driven
requests.

if A, then please do learn about HTTP first. then you'll not only
realize what you really need, but will also be in position to make
your applications like you want.

if B, then please tell us what is it that you don't want.

--
Javier

lankesh87

unread,
Oct 12, 2011, 10:39:06 AM10/12/11
to Django users
Actually my project guide is asking me to search for ajax replacement
in django. So that way we dont have to use ajax.

I mean if we could only refrsh particular part in our web page without
refreshing the whole page "using django".

Thanx in advance and pardone me for my foolish questions as i am new
to django and web but i do have some basic knowledge on
how html functions.

On Oct 12, 7:24 pm, Javier Guerra Giraldez <jav...@guerrag.com> wrote:

Chandrakant Kumar

unread,
Oct 12, 2011, 10:50:41 AM10/12/11
to django...@googlegroups.com

You are another 'garbage' product of our country's shitty education system.

Markus Gattol

unread,
Oct 12, 2011, 10:54:00 AM10/12/11
to django...@googlegroups.com
If you don't want to do AJAX but still need to have a bidirectional link between client and server then websockets is probably what you want.

Donald Stufft

unread,
Oct 12, 2011, 10:55:29 AM10/12/11
to django...@googlegroups.com
I don't think there's any reason to insult anyone, let's be civil.
--
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...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Phang Mulianto

unread,
Oct 12, 2011, 11:06:24 AM10/12/11
to django...@googlegroups.com

but for the web html standart you need ajax.

maybe you can use some javascript framework like prototype+scripatoulus or jquery to simply work with ajax and browser compatibility issue.

lankesh87

unread,
Oct 12, 2011, 11:30:48 AM10/12/11
to Django users
As far I can understand from ur opinions is that to load contents
without refreshing the web page we will have to use ajax and

as python being server side scripting language will not be helpful in
this case. So anyhow I will have to use ajax.. do correct me if i'm
wrong..

once again thank u all for ur time and help.

On Oct 12, 8:06 pm, Phang Mulianto <braveh...@gmail.com> wrote:
> but for the web html standart you need ajax.
>
> maybe you can use some javascript framework like prototype+scripatoulus or
> jquery to simply work with ajax and browser compatibility issue.

Chandrakant Kumar

unread,
Oct 12, 2011, 11:32:44 AM10/12/11
to django...@googlegroups.com

I am sorry everybody and especially lankesh87, I should not have used those words. I had just got into an argument with my dean. Sorry again.

Brian Schott

unread,
Oct 12, 2011, 11:34:53 AM10/12/11
to django...@googlegroups.com
This is a bit old-school, but you could do this by using meta-refresh on a frame.  I think that should still work in most browsers.  
http://en.wikipedia.org/wiki/Meta_refresh

Basically, you can place an iframe inside your base.html template that includes an <iframe> link to your dynamic content.   

Create a iframe_base.html template file that has the meta refresh tag included in <head> section and just the iframe parts should refresh.  

Not sure if this is what you want, and not sure this is a good idea, but it doesn't require javascript.

Brian Schott


Javier Guerra Giraldez

unread,
Oct 12, 2011, 11:38:48 AM10/12/11
to django...@googlegroups.com
On Wed, Oct 12, 2011 at 9:39 AM, lankesh87 <lanke...@gmail.com> wrote:
> I mean if we could only refrsh particular part in our web page without
> refreshing the whole page "using django".

i think you really need to check how HTTP works.

in HTTP, the server can't "push" anything to the browser. the browser
has to ask for it.

Django runs exclusively in the server.

the only browse-side coding environments are javascript and some
plugins (flash, Java, silverlight). in general, only Javascript is
practical.

you want to replace part of the webpage with different content,
probably in response of some user interaction. That has to be
initiated at the browser. Since you don't want to replace the whole
page, it has to be some Javascript code that 'pulls' the new content
from the server and replaces some part of the page with it.

guess what? that javascript-driven requests are called AJAX (even if
the 'X' doesn't imply XML anymore).

using a javascript library it can be real simple. in jQuery it's:

$('#partid').load('http://some.url/with/new/content');

from the Django point of view, it will simply get a request for the
new URL, and it should return the partial content. jQuery will patch
it replacing the content of the '#partid' element of the page


but you _really_ have to understand HTTP and javascript to go from
there to anywhere else.


--
Javier

Tom Evans

unread,
Oct 12, 2011, 11:40:34 AM10/12/11
to django...@googlegroups.com
On Wed, Oct 12, 2011 at 3:24 PM, Javier Guerra Giraldez
<jav...@guerrag.com> wrote:
> On Wed, Oct 12, 2011 at 9:17 AM, lankesh87 <lanke...@gmail.com> wrote:
>>  I am developing a web application where i need ajax like features.
>> But I don't want to use ajax, so my question is- "is there any way to
>> perform ajax like functions in django?"
>
> that kind of specifications (ajax-like but no ajax) sound very weird
> to me.

It's definitely weird, but its not crazy. I'm almost certain the OP
does want to use AJAX, but there are AJAX-like techniques that we used
to do AJAX-like things before XMLHttpRequest existed.

The most common way is to use javascript to programmatically load
content into a hidden <iframe>. The returned content should have a
<script> tag at the end of the content that runs after the content has
been loaded to achieve whatever it is that you wanted to achieve, eg
move the loaded content into a visible part of the webpage, or replace
some content with the loaded content.

You can also use the existence of javascript to make the iframe
visible/not visible. I've used this technique to load content
asynchronously to the main page, which then works regardless of
whether the user has javascript enabled - if it isn't enabled, the
content loads into the (now visible) iframe, otherwise if javascript
is available it is loaded into the (invisible) iframe, and javascript
used to move the content from the iframe to the appropriate part of
the main page.

It's not AJAX, but it is AJAX-like. It's also bloody stupid, use AJAX.

Cheers

Tom

Kurtis Mullins

unread,
Oct 12, 2011, 11:41:17 AM10/12/11
to django...@googlegroups.com
You could also use Javascript to just hide and display information as you need it. No Ajax involved -- just need to give all of the data to the browser up front.



--
Javier

william ratcliff

unread,
Oct 12, 2011, 11:42:35 AM10/12/11
to django...@googlegroups.com
I think the OP should ask his manager why they wish to avoid using ajax.   For example, is it sufficient if the page degrades gracefully for those not running javascript?

lankesh87

unread,
Oct 12, 2011, 12:37:53 PM10/12/11
to Django users
thank you to all for your support.
I learnt my lessons.
I have to go back to AJAX.

Thanks again for your help. It was much needed.

On Oct 12, 8:42 pm, william ratcliff <william.ratcl...@gmail.com>
wrote:
> I think the OP should ask his manager why they wish to avoid using ajax.
> For example, is it sufficient if the page degrades gracefully for those not
> running javascript?
>
> On Wed, Oct 12, 2011 at 11:40 AM, Tom Evans <tevans...@googlemail.com>wrote:
>
>
>
>
>
>
>
> > On Wed, Oct 12, 2011 at 3:24 PM, Javier Guerra Giraldez
> > <jav...@guerrag.com> wrote:

lankesh87

unread,
Oct 12, 2011, 12:40:08 PM10/12/11
to Django users
thank you all for your support.
I learnt my lessons.
I have to go back to AJAX.

Thank you again I really needed your help.

I guess I'll be hanging around as I am starting to like python and
django.

On Oct 12, 8:42 pm, william ratcliff <william.ratcl...@gmail.com>
wrote:
> I think the OP should ask his manager why they wish to avoid using ajax.
> For example, is it sufficient if the page degrades gracefully for those not
> running javascript?
>
> On Wed, Oct 12, 2011 at 11:40 AM, Tom Evans <tevans...@googlemail.com>wrote:
>
>
>
>
>
>
>
> > On Wed, Oct 12, 2011 at 3:24 PM, Javier Guerra Giraldez
> > <jav...@guerrag.com> wrote:

Micky Hulse

unread,
Oct 12, 2011, 12:40:17 PM10/12/11
to django...@googlegroups.com
On Wed, Oct 12, 2011 at 7:39 AM, lankesh87 <lanke...@gmail.com> wrote:
> Actually my project guide is asking me to search for ajax replacement
> in django. So that way we dont have to use ajax.

Perhaps it's a trick question?

Maybe you project guide does not like the "Ajax" buzzword? :)

Just call it XHR:

<http://www.quirksmode.org/js/xmlhttp.html>
<http://en.wikipedia.org/wiki/XMLHttpRequest>

On a more serious note...

I have never used, and this might be a wild goose chase, but what
about html5 WebSockets?

<http://pypi.python.org/pypi/django-websocket>
<http://dev.w3.org/html5/websockets/>

The first answer here does a nice job at explaining the difference
between XMLHttpRequest and WebSocket technology:

<http://stackoverflow.com/questions/3163192/will-websockets-in-html-5-replace-ajax-for-partial-page-refreshes>

Good luck!

Cheers,
M

Chandrakant Kumar

unread,
Oct 12, 2011, 12:54:22 PM10/12/11
to django...@googlegroups.com

But, isn't HTML5 is still work in progress? I mean, how will it behave
on older browsers?

Sultan Imanhodjaev

unread,
Oct 12, 2011, 12:57:43 PM10/12/11
to django...@googlegroups.com

Hello,

Did you look at dajax and dajaxice extensions for django so far? It might help.

Micky Hulse

unread,
Oct 12, 2011, 1:00:47 PM10/12/11
to django...@googlegroups.com
On Wed, Oct 12, 2011 at 9:54 AM, Chandrakant Kumar
<k.03c...@gmail.com> wrote:
> But, isn't HTML5 is still work in progress? I mean, how will it behave on
> older browsers?

Good point. I guess it depends on the requirements of the project.

From what I read, this sounds like a school project, so why not take
the time to explore state of the art web technologies?

Cheers,
Micky

Russell Keith-Magee

unread,
Oct 12, 2011, 7:20:36 PM10/12/11
to django...@googlegroups.com
A good thing you did. For everyone's benefit -- this kind of language
and sentiment *will not* be tolerated on django-users. If you can't
keep a civil tongue, you will be asked to leave.

Yours,
Russ Magee %-)

Sells, Fred

unread,
Oct 13, 2011, 9:34:34 AM10/13/11
to django...@googlegroups.com
> On Wed, Oct 12, 2011 at 9:17 AM, lankesh87 <lankesh...@gmail.com> wrote:
> >  I am developing a web application where i need ajax like features.
> > But I don't want to use ajax, so my question is- "is there any way to
> > perform ajax like functions in django?"
>
Use Flex, it's easier.

Babatunde Akinyanmi

unread,
Oct 14, 2011, 7:47:21 AM10/14/11
to django...@googlegroups.com
From what Iankesh said initially, I think he is having problems using
ajax to load part of a page not ajax as a whole.
Iankesh, it is possible to load only a portion of a page with ajax.

> --
> 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...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

--
Sent from my mobile device

Phang Mulianto

unread,
Oct 14, 2011, 8:41:32 AM10/14/11
to django...@googlegroups.com

ajax use usualy load a div part of html with new content fetch from the server when user do something,like click a submit button. and django process the request as a simple usual request.

i have using prototype+scriptocolous for the simple syntax to make an ajax form.
i see the jquery version also but a bit trouble coz need to add the event manually.

and remember the crsf token when using ajax request..will need it generated properly..

anyone using prototype to?

or anyone have better way with ajax

Kevin

unread,
Oct 18, 2011, 1:09:20 AM10/18/11
to Django users
Just a simple thought, if you'd prefer to avoid JavaScript/client-side
scripting entirely, and only code using Python. It might be an idea
to look at Pyjamas to generate your page. It technically uses Ajax,
but from the programmers point of view, it feels more like coding a
desktop application. The exposed functions on the django server are
mapped as Python functions in pyjamas, so coding Ajax in this method
seems very natural for a python programmer. Depending on what type of
web application you are attempting to build, this might be a good
solution for you. The tools you use all come down to what the end
result should be. Is it a website or a web application? Should the
look and feel be more like a desktop app, or a newspaper? Pyjamas
also strives for cross-platform/browser compatibility for a true code
once, run anywhere feeling without the Java. Pyjamas also supports
some HTML5 features such as the canvas to further a desktop app like
feeling for the end user. One can also mix traditional HTML and a
Pyjamas app onto a single page. If, for example, your project
requires a small widget which updates from the server constantly(news
feed/chatbox), you can make the entire site using standard HTML/CSS
and embed a Pyjamas app into a DIV tag on the site.

Hopefully this gives you some ideas.

On Oct 14, 7:41 am, Phang Mulianto <braveh...@gmail.com> wrote:
> ajax use usualy load a div part of html with new content fetch from the
> server when user do something,like click a submit button. and django process
> the request as a simple usual request.
>
> i have using prototype+scriptocolous for the simple syntax to make an ajax
> form.
> i see the jquery version also but a bit trouble coz need to add the event
> manually.
>
> and remember the crsf token when using ajax request..will need it generated
> properly..
>
> anyone using prototype to?
>
> or anyone have better way with ajax
> On Oct 14, 2011 7:47 PM, "Babatunde Akinyanmi" <tundeba...@gmail.com> wrote:
>
>
>
>
>
>
>
> > From what Iankesh said initially, I think he is having problems using
> > ajax to load part of a page not ajax as a whole.
> > Iankesh, it is possible to load only a portion of a page with ajax.
>
Reply all
Reply to author
Forward
0 new messages