Я не могу публиковать данные из представления в другое представление, используя реверс и HttpResponseRedirect?
Я пытаюсь отправить данные из отправленной формы в другое представление в моем приложении, но
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
вид №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))
вид # 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'),
Кажется, что метод "form.cleaned_data" возвращает ключ выбранного значения в моем поле выбора, а не само значение это то, что я получил после отправки моей формы