I am new here. In an internship context, I have to developp a website in which the user will have the opportunity to select a program, a localisation or a thematic he wants to visualise in a heatmap.
To do so, I decided to use Django. I am encoutering 2 issues:
For now I have thought about using new_var = table.objects.annotate but i cannot join the two newly variables... Do you have any ideas?
For now I have that:
(views.py)
''' def map(request):
m = folium.Map(location=[-17.4889,-149.90017], zoom_start=11, tiles='CartoDB Dark_Matter', control_scale=(True))
if request.method == 'GET':
featured_filter = request.GET.get('site_name')
if request.GET.get('nom_site'):
data_list = table.objects.filter(localisation = featured_filter).values_list('latitude', 'longitude', 'proportion')
else :
data_list = table.objects.all().values_list('latitude', 'longitude', 'proportion')
plugins.HeatMap(data_list).add_to(m)
m = m._repr_html_()
context = {
'm': m,
"showname": name}
return render(request, 'map.html', context)
'''
(map.html)
Select a site {% for nom in showname %} {{name.localisation}} {% endfor %}My issue is that "featured_filter" is an empty QuerySet. So can I get the selected value from the html interface into my python code?
Thank you for your help !
I do not understand very well what you want exactly, but I'll give you a series of tips to see if they can help you:
1 - If what you need is to join two database tables, you can use a many-to-many relationships ( Documentation )
2 - It is possible that this problem is better to face it with a form and the POST method:
3 - If you do not want to use forms, you can create a Custom Template Tags and JavaScript. This method is more complicated so I do not recommend it. ( Custom template tag ) ( InnerHTML Javascript )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.