Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

109
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda