<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>
<div>
{% for current_addr
in mymodel.addresses.all
%}
{{ current_addr
.description | safe}}
Latitude : {{ current_addr
.lat }},
<br>
Longitude : {{ current_addr
.lon }},
<br>
{% endfor %}
</div>
--
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 django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
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/23f8bdd5-86b6-40d3-9cb6-964a8d808a6c%40googlegroups.com.
<script type="text/javascript" src="{% static "js/geomap_var.js" %}"></script>
<script type="text/javascript">
my_markers = [
{{ mymodel
.set_first_call_true }}
{% for current_addr
in mymodel.addresses.all
%}
{% if not mymodel.
first_call %},{% endif %}
{
lat: {{ current_addr
.lat }},
lon: {{ current_addr
.lon }},
description: {{ current_addr
.description | safe }}
}
{{ mymodel
.set_first_call_false
}}
{% endfor %}
];
</script>
<script type="text/javascript" src="{% static "js/geomap_body.js" %}"></script>
mymodel
.set_first_call_true
or mymodel
.set_first_call_false
, it inserts a "none" inside my javascript code.--
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 django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
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/232757e4-0a4b-450f-808d-764453783dea%40googlegroups.com.
I don't quite follow what you're doing with set_first_call_true and set_first_call_false. Are you using that to control the for loop behavior?If you are, take a look at https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#for. Django's template language has that built in.If you're pushing to an array like in your initial example, you don't need to handle commas at all. Here's an example out of Chrome's dev tools:> var a = []> a.push('foo')> a.push('bar')> a< ["foo", "bar"]If you want to define it in one go, try something more like:<script type="text/javascript">my_markers = [{% for current_addr in mymodel.addresses.all %}{lat: {{ current_addr.lat }},lon: {{ current_addr.lon }},description: {{ current_addr.description | safe }}}{% if not forloop.last %}, {% endif %}{% endfor %}];</script>