Include django views in other web sites

6 views
Skip to first unread message

Alessandro

unread,
Jul 3, 2008, 7:28:44 AM7/3/08
to django...@googlegroups.com
I need to include some django output in other web pages. The problem
is that Sometimes I cannot use server side includes on the other side,
and I don't know how to do.

I thought maybe some javascript or ajax to include with a <script> in
the destination page, but how can I do it?

Must I write a javascript with document.write on the django side or
can I import the html output directly with a javascript and a browser
side include?

Do you have any examples?
--
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

David Christiansen

unread,
Jul 3, 2008, 9:26:49 AM7/3/08
to Django users
Just a thought, but can you put this information in an iframe?

Jeff Anderson

unread,
Jul 3, 2008, 9:28:03 AM7/3/08
to django...@googlegroups.com
Alessandro wrote:
> I need to include some django output in other web pages. The problem
> is that Sometimes I cannot use server side includes on the other side,
> and I don't know how to do.
>
> I thought maybe some javascript or ajax to include with a <script> in
> the destination page, but how can I do it?
>
> Must I write a javascript with document.write on the django side or
> can I import the html output directly with a javascript and a browser
> side include?
>
> Do you have any examples?
>
I have used the django template system to generate web pages independent
of a django project.

First I created a settings.py that only has the TEMPLATE_DIRS setting.
Next, I created my template.
Last, I created a cgi script that loads and renders my template. I used
a more generic python CGI module to handle post data.

If you don't want to use the django template system exclusively,
consider using an iframe for a "browser side include".

Cheers!

Jeff Anderson

signature.asc

Alessandro Ronchi

unread,
Jul 4, 2008, 8:19:22 AM7/4/08
to Django users


On 3 Lug, 15:26, David Christiansen <d...@dis.dk> wrote:
> Just a thought, but can you put this information in an iframe?

Yes I've done, but this solution has two problems:

1) Blogger.com and other sites doesn't permits iframes
2) Referrers tracking is wrong with iframes, because if the user
clicks a link it seems to come to the included domain, not from the
referring domain.

So, the solution should be to use the same technics of statistics
sites, but I don't know hot to do it.

Alessandro Ronchi

unread,
Jul 4, 2008, 11:41:34 AM7/4/08
to django...@googlegroups.com
2008/7/3, Jeff Anderson <jeff...@programmerq.net>:

> I have used the django template system to generate web pages independent of
> a django project.
>
> First I created a settings.py that only has the TEMPLATE_DIRS setting.
> Next, I created my template.
> Last, I created a cgi script that loads and renders my template. I used a
> more generic python CGI module to handle post data.
>
> If you don't want to use the django template system exclusively, consider
> using an iframe for a "browser side include".

I cannot use any server side technologies and I cannot use iframes.

Alaa Salman

unread,
Jul 4, 2008, 12:26:48 PM7/4/08
to Django users

On Jul 4, 6:41 pm, "Alessandro Ronchi" <alessandro.ron...@soasi.com>
wrote:
> 2008/7/3, Jeff Anderson <jeffe...@programmerq.net>:
>
> >  I have used the django template system to generate web pages independent of
> > a django project.
>
> >  First I created a settings.py that only has the TEMPLATE_DIRS setting.
> >  Next, I created my template.
> >  Last, I created a cgi script that loads and renders my template. I used a
> > more generic python CGI module to handle post data.
>
> >  If you don't want to use the django template system exclusively, consider
> > using an iframe for a "browser side include".
>
> I cannot use any server side technologies and I cannot use iframes.
>

If i understand you correctly, what you need is just AJAX. Just have
your views produce xml or json or perhaps even html snippets. And use
any javascript suite to call this view and then insert the data into
your page. I prefer spitting out data in a json format, and then using
something like YUI or jquery to call and then parse.

Alessandro Ronchi

unread,
Jul 4, 2008, 6:59:37 PM7/4/08
to django...@googlegroups.com
2008/7/4, Alaa Salman <alaas...@gmail.com>:

> If i understand you correctly, what you need is just AJAX. Just have
> your views produce xml or json or perhaps even html snippets. And use
> any javascript suite to call this view and then insert the data into
> your page. I prefer spitting out data in a json format, and then using
> something like YUI or jquery to call and then parse.

Do you have any example?

Reply all
Reply to author
Forward
0 new messages