django - i can't posting data from view to another view using reverse and HttpResponseRedirect? -
i'm trying sending data submitted form view in app
forms.py
class filterform(forms.form): currency = forms.choicefield(choices=currency_choices) continent = forms.choicefield(choices=select_continent()) country = forms.choicefield(choices=select_country())
views.py
view #1
def filtrer(request): if request.method == 'post': form = filterform(request.post) if form.is_valid(): currency = form.cleaned_data['currency'] continent = form.cleaned_data['continent'] country = form.cleaned_data['country'] url = reverse('affiche_filter', args=(), kwargs={'continent':continent,'country':country,'currency':currency}) return httpresponseredirect(url) else: form =filterform() return render_to_response('filter.html', {'form': form }, requestcontext(request))
view#2
def affiche_filter(request,continent, country,currency): data = select_where(continent, country, currency) symbol = convertsymbol(currency) return render_to_response('affiche_continent.html', {'data': data,'symbol':symbol }, requestcontext(request))
urls.py
urlpatterns = patterns('myform.views', url(r'^filtrer$', 'filtrer'), url(r'^affiche_filter/(?p<continent>[-\w]+)/(?p<country>[-\w]+)/(?p<currency>[-\w]+)/$', 'affiche_filter', name='affiche_filter'),
seems method "form.cleaned_data" return key of selected value in choicefield not the value got after submitted form
Comments
Post a Comment