Must be simple solution. But I do not see it. Please help me. Looks like 'gorod' is in request but when i trying cleaned_data() it gives me KeyError
KeyError at /ticket/
'gorod'
Request Method: POST
Request URL: http://localhost:8000/ticket/
Exception Type: KeyError
Exception Value:
'gorod'
Exception Location: C:\Documents and Settings\POLINOM\web\website\orders\views.py in SaveOrder2, line 93
Python Executable: C:\Python26\python.exe
Python Version: 2.6.5
Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in get_response
92. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Documents and Settings\POLINOM\web\website\orders\views.py" in ticket
136. adr_form=MakeForm2(request)
File "C:\Documents and Settings\POLINOM\web\website\orders\views.py" in MakeForm2
58. SaveOrder2(request,form)
File "C:\Documents and Settings\POLINOM\web\website\orders\views.py" in SaveOrder2
95. gorod=form.cleaned_data['gorod']
Exception Type: KeyError at /ticket/
Exception Value: 'gorod'
My form:
class MumForm(AddressForm):
CITY_CHOICES = (
(0,'August,11 - Washington, BlackCat'),
(1,'August,12 - Philadelphia, WorldLiveCafe'),
(2,'August,13 - New York, Irving Plaza'),
(3,'August,14 - Boston, Middle East'),
(4,'August,15 - Montreal, Cabaret Du Musee Juste Pour Rire'),
(5,'August,16 - Toronto, Mod club'),
(6,'August,17 - Cleveland, Beachland Tavern'),
(7,'August,18 - ------------------------'),
(9,'August,19 - ------------------------'),
(10,'August,20 - Atlanta, Masquerade'),
(11,'August,22 - Chicago, Empty Bottle'),
(12,'August,23 - Milwaukee, Shank Hall'),
(13,'August,24 - Minneapolis, Varsity (promoted by 1st Avenue)'),
(14,'August,25 - Winnipeg, Cowboys'),
(15,'August,27 - Edmonton, The Starlite Room'),
(16,'August,28 - Calgary, The Den'),
(17,'August,29 - Vancouver, Commodore Ballroom'),
(18,"August,31 - Seattle, Neumo's"),
(19,'September,01 - Portland, Howthorne Theatre'),
(20,'September,02 - San Francisco, Bottom Of The Hill'),
(21,'September,03 - Los Angeles, The Roxy'),
(22,'September,04 - Salt Lake City, Urban Lounge'),
(23,'September,05 - Denver, Bluebird Theatre'),
(24,'September,06 - Kansas City, The Record Bar'),
(25,'September,07 - Dallas, The Loft'),
(26,"September,08 - Austin, Emo's"),
)
gorod = forms.ChoiceField(choices=CITY_CHOICES, label="Выберите город в котором вы хотите пойти на концерт")
note = forms.CharField(max_length=1500,label=u'Заметка',widget=forms.Textarea)
This is inherits from ather form which is:
class AddressForm(forms.Form):
address = forms.CharField(label=u"Адрес",max_length=200,required=True,widget=forms.TextInput(attrs={'size':60}))
city = forms.CharField(label=u"Город",max_length=50,required=True)
country = forms.ChoiceField(label=u"Страна",required=True,choices=COUNTRIES)
state = forms.ChoiceField(label=u"Штат/Провинция",required=False, choices=StateProvince().get_all_states(), error_messages={'invalid_choice':u'нет среди допустимых значений. Пожалуйста, выберите правильный вариант'})
zip = forms.CharField(label=u"Почтовый код",max_length=10,widget=forms.TextInput(attrs={'size':8}),required=True)
phone_number = forms.CharField(label=u"Номер телефона",required=False)
there is two models which i'm working with:
class Order(models.Model):
STATUS_CHOICES=[
(1, 'Send'),
(0, 'Not_send'),
]
user=models.ForeignKey(User)
product=models.ForeignKey(Product)
status = models.CharField(max_length=1,choices=STATUS_CHOICES)
country = models.CharField(max_length=2)
state = models.CharField(max_length=50)
zip = models.CharField(max_length=10)
city = models.CharField(max_length=50)
street = models.CharField(max_length=200)
phone=models.CharField(max_length=20)
def __unicode__(self):
return 'Order by ' + self.user
class TicketProp(models.Model):
order=models.ForeignKey(Order)
note=models.CharField(max_length=1500)
gorod=models.CharField(max_length=2)