Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
Return value from html to django with range input every time its value changes

I have a project that takes a value from my website (django framework) and pass it back to django so that it can be used to run some scripts in case to dim the lights of my house (IOT project).
I've found this code in django docs tha does this by a submit button but in my case it would be better with range input. What i exactly am looking for is to send the value back every time the slider changes position just like when i press submit button.Thanks in advance.

here my code.html file

{% extends "personal/header.html" %}

{% block content %}

<form action="/code/" method="post">

{% csrf_token %}
{{ form}}
<input type="submit" value="Submit"  /> 

</form>

{% endblock %}

And this is on my views

def get_name(request):
# if this is a POST request we need to process the form data
if request.method == 'POST':
    # create a form instance and populate it with data from the request:
    form = NameForm(request.POST)
    # check whether it's valid:
    if form.is_valid():
        # process the data in form.cleaned_data as required
        # ...
        # redirect to a new URL:
        print(form['your_name']) # outputs for example : <input type="text" name="your_name" value="34" required id="id_your_name" /> I would like to know how to print just its value :)

        return HttpResponseRedirect('/code/')

# if a GET (or any other method) we'll create a blank form
else:
    form = NameForm()

return render(request, 'personal/code.html', {'form': form})

And this is the forms.py file

from django import forms

class NameForm(forms.Form):
your_name = forms.DurationField(label='% Brightness ')

Here is a picture of the working code tha i want to replace with a range input instead of submit

For example something like this(Range input pic

Also this is what is happening to django (python manage.py runserver) when i submit for example the value of 345 (django shell) htt//a//ps://i.stack.imgur.com/0fMtG.png (remove the //a//)

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!