1👍
You need to think about how the web browser and the server (Django) communicate.
The browser makes a ‘get’ request to a url on the server. In Django you have an urls.py file which determines which view will handle requests to that url. For example there will be a view which renders a template containing the HTML code for the poll form.
When the user submits the poll, the browser makes a ‘post’ request, sending the form data for the poll to the server – to a specific Django view which handles saving the poll vote to the database. Usually in Django we’d use the same view function for both the get and the post for a form – see this answer for more details: https://stackoverflow.com/a/21114637/202168
It’s not clear whether you want to show the progress bar initially, or only after they’ve submitted their vote. Either way you just need to calculate the relevant values for percentage and sum of users in your Django view and pass those values into the template, which renders the HTML sent back to the browser.
If you’re using an HTML5 progress bar you don’t even need jQuery. Unless you want a user to see the progress bar changing as other users submit their votes (much more complicated) you don’t need any ‘ajax’ stuff either.
I suggest first you start with the Django tutorial:
https://docs.djangoproject.com/en/dev/intro/tutorial01/
0👍
So to be accurate the helper.py imports register from jingo. This means you call the function instantly into template. Furthermore I used instead of for my purpose.
helper.py
from jingo import register
@register.filter
def get_value():
return value
into template
<meter min="0" value="{{ <app_name>|get_value }} max="1"></meter>