python - Django Form Selection Change Value in URL -
python - Django Form Selection Change Value in URL -
python 3.3.2, django 1.6.5, fedora 20
i have django form set default selection value in url, , limit queryset of form based on value.
for example:
url:
http://fakesite.com/myapp/add_activity/?sport=run
relevant views.py:
urlsport = sport.objects.get(name = request.get.get('sport')) form.fields["sport"].initial = urlsport form.fields["gear"].queryset = gear.objects.filter(sport_id=urlsport)
i'd create such if user selects different sport, url change/reload form.fields["gear"].queryset filter re-applied.
any ideas how can this? right approach?
python django django-forms
Comments
Post a Comment