I have an application with the following structure:
STO
โโโ __init__.py
โโโ jsonopenlayers
โ โโโ __init__.py
โ โโโ models.py
โ โโโ static
โ โ โโโ css
โ โ โ โโโ STO.css
โ โ โโโ js
โ โ โโโ renderMaps.js
โ โโโ tests.py
โ โโโ views.py
โโโ manage.py
โโโ settings.py
โโโ templates
โ โโโ jsonopenlayers
โ โโโ index.html
โโโ urls.py
Static files are found, but I have the problem that inside renderMaps.js
I have some Django template tag to be interpreted.
How can I tell Django to parse also that, in addition to my index.html?
Thanks in advance.
--
Alessandro Candini
MEEO S.r.l.
Via Saragat 9
I-44122 Ferrara, Italy
Tel: +39 0532 1861501
Fax: +39 0532 1861637
http://www.meeo.it
========================================
"ATTENZIONE:le informazioni contenute in questo messaggio sono
da considerarsi confidenziali ed il loro utilizzo รจ riservato unicamente
al destinatario sopra indicato. Chi dovesse ricevere questo messaggio
per errore รจ tenuto ad informare il mittente ed a rimuoverlo
definitivamente da ogni supporto elettronico o cartaceo."
"WARNING:This message contains confidential and/or proprietary
information which may be subject to privilege or immunity and which
is intended for use of its addressee only. Should you receive this
message in error, you are kindly requested to inform the sender and
to definitively remove it from any paper or electronic format."
The only way you can manage this is to deliver that file not as a
static file, but as something that has been passed through the
template engine. The template engine can generate any content, be sure
to pass the correct content type ('text/javascript') when you return
the response, and use the cache_page decorator to avoid re-doing it
lots of times.
That is a pain, so a common work-around I use is to re-work it so that
the url to use is something that is passed to the function, and then
insert it into the appropriate templates.
Cheers
Tom
I have deleted renderMaps.js and created a new template named
index_renderMaps.html, containing only a script tag with inside the
javascript previously into renderMaps.js.
After that I have simply used an {% include "index_renderMaps.html" %}
into index.html template.
In the main HTML, change the tag to something like <script href='/
myapp/jscript/renderMaps/'>
In your "urls.py" add something like
('/myapp/jscript/renderMaps','myapp.views.rendermap')
then in your views.py create a view:
def rendermap(request):
# create the variables you need here
var1 = "Hello"
address = Address.objects.get(id=1)
:
return render_to_response('renderMaps.js', locals(),
RequestContext(request))
You can see the idea, anyhow!
> Fax: +39 0532 1861637http://www.meeo.it