I have a form that looks like this - a form that has a drop down select:
class ContactUs(forms.Form):
TYPES = (
('hi', 'Say Hi'),
('restaurant', 'Introducing a Restaurant'),
('event', 'An Event is coming up'),
('promotion', 'Interesting Promotion'),
)
subject = forms.ChoiceField(choices=TYPES)
I would like to read from request.GET.get('subject')
so that I can dynamically select the choices
so it would look something like this:
subject = forms.ChoiceField(choices=TYPES, initial=request.GET.get('subject'))
Obviously the choices are: hi, restaurant, event or promotion and the url looking something like this:
http://localhost:8000/contact?subject=promotion
problem is I cannot do the request.GET.get('subject')
How can we solve this?
contact_us = ContactUs(initial={'subject': request.GET.get('subject')})
Django form initial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With