On 11/25/2011 03:06 PM, Tom Evans wrote:
On Fri, Nov 25, 2011 at 11:25 AM, Alessandro Candini<[email protected]>  wrote:
Hi everybody.

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.

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

Thank you, but I adopted the method indicated here: http://stackoverflow.com/questions/6008908/use-django-template-tags-in-jquery-javascript

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.

--
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."

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

Reply via email to