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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -