Hello

I am currently developping a django geolocalisation application. Therefore, 
I need both python and javascript.
I would like to give some parameters to a script in a template, that is to 
say, in my template, I want to use the script tag to define/modify some 
javascript variables.
Here is my code (that doesn't work) :
<script type="text/javascript" src="{% static "js/geomap_var.js" %}"
></script>
{% for current_addr in mymodel.addresses.all %}
    <script type="text/javascript">
    my_markers.push(
        {
            lat: {{current_addr.lat}},
            lon: {{current_addr.lon}},
            description: {{current_addr.description | safe }}
        }
        );
    </script>
{% endfor %}
<script type="text/javascript" src="{% static "js/geomap_body.js" %}"
></script>


When I define the array of objects my_markers in my script by giving only 
"hard-coded" numbers and strings, it works fine, so I guess that the 
problem is to recognize and evaluate the lat, lon, and description 
attributes of my address class.

And I also don't know how to display the value of a javascript array in a 
template, so it makes it quite hard for debugging.

If it helps, mymodel is a model that has a field : addresses = 
ManyToManyField(address)


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3b565774-f4d5-4791-b83f-51df7da9ed83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to