javascript - Django modelchoicefield submit -


i have form shown dropdown list @ template. when user selects 1 option, javascript function called , page reloaded. want capture value of selected option using request.post.get(...), can't manage set submission post. have found approaches using ajax, not familiar it. there easier way it?

home.html:

<script>     function refresh(){         window.location.href = 'http://127.0.0.1:8000/home';     } </script>  <form>     {{ days }} </form> 

models.py:

class date(models.model):     day = models.charfield(max_length=200, default='')     month = models.charfield(max_lenght=200, default='')     def __unicode__(self):         return self.day  class cronform(forms.form):     days = forms.modelchoicefield(queryset=date.objects.all().order_by('alias'), widget=forms.select(attrs={"onchange":'refresh()'})) 

submit form on change

class cronform(forms.form):     days = forms.modelchoicefield(queryset=date.objects.all().order_by('alias'),             widget=forms.select(attrs={"onchange":'submit()'})) 

and edit template to

<form method=post> 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -