django form wizard, does not go to second step -
i trying perform following using django :
- wizard containing 2 formds
- first form simple form containing ajax compute automatically fields
- second form user registration
the problem following :
- the first form displayed correctly , ajax within page working fine
- the second form never displayed after pushing on button "submit"
the code follows :
urls.py
from forms import insertpropertyform1, insertpropertyform2 views import insertpropertywizard urlpatterns = patterns('', url(r'^addproperty/$', insertpropertywizard.as_view([insertpropertyform1, insertpropertyform2]), name='addproperty'), )
views.py
forms = [("property", insertpropertyform1), ("test", insertpropertyform2) ] templates = {'0': 'realestate/addproperty.html', '1' : 'realestate/test.html', } class insertpropertywizard(sessionwizardview): def get_template_names(self): print ("next step !!!!! " + str(self.steps.current)) return [templates[self.steps.current]] def done(self, form_list, **kwargs): print "wizard done" #do_something_with_the_form_data(form_list) return httpresponseredirect('http://to_fill_in')
realestate/addproperty.html
{% extends 'realestate/base.html' %} {% load socialaccount %} {% load i18n %} {% block head %} {{ wizard.form.media }} {% endblock %} {% block content %} <h1> insert ad </h1> <p>step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}</p> <form class="form-horizontal" role="form" action="" method="post">{% csrf_token %} <table> {{ wizard.management_form }} </table> {{ form.non_field_errors }} <fieldset> <legend>localisation</legend> <div class="form-group"> {{ form.country.errors }} <label class="col-lg-1" for="id_country">{{form.country.label}}</label> <div class="col-lg-1"> {{ form.country }} </div> </div> </fieldset> </fieldset> {% if wizard.steps.prev %} <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.first }}">{% trans "first step" %} </button> <button name="wizard_goto_step" type="submit" value="{{ wizard.steps.prev }}">{% trans "prev step" %} </button> {% endif %} <input type="submit" value="{% trans "submit" %}"/> </form> {% endblock %}
just thought someone.
problem 1 of field not defined in form , forgot include in template.
the behaviour of wizard correct. got stuc on first page did not display error on screen field not displayed.
got me crazy fault.
cheers
Comments
Post a Comment