This is my view:
CHOICES = (('10','10'), ('20','20'),('30','30'), ('50','50'))
class Droplist (forms.Form):
number = forms.ChoiceField(choices = CHOICES)
def page_objects(request):
if request.method == 'POST': # If the form has been submitted...
form = Droplist(request.POST) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
pass #pages = form.cleaned_data['value']
#return AutoPaginateNode(paginate_by=pages) # Redirect after POST
else:
form = Droplist() # An unbound form
return render_to_response('pagination.html', {'form': form })
This is my template:
<form action="/submit/" method="post">{% csrf_token %}
{{ form }}
<input type="submit" value="Select">
</form>
how can i render my form, because i need to have a dropdown box with choices on template? what i've missed?
You need to use
{{ form.as_p }}
:You can also use
{{ form.as_table }}
to output table rows but you'll need to provide your own<table>
andform.as_ul
to output list items:You can find more information on Displaying a form using a template on Django's documentation