1👍
✅
Try a view similar to the following:
def state(request, country_id, state_id):
my_state = State.objects.all()[0]
my_country = Country.objects.all()[0]
return render_to_response("template.html", {'state': my_state, 'country': my country })
The function above is nonsensical, but should not produce an error.
If you are defining country and state via some select tool on the web page, then
it will never work, as this is being evaluated BEFORE it goes to the users browser.
I’m not saying you can not get the form to work, just that this approach is wrong.
0👍
When you use only 1 parameter, is my_App.views.country being used? Try reversing the order of the last 2 urls…
url(r'^my_index/(?P<country_id>\d+)/state/(?P<state_id>\d+)/$', 'my_App.views.state', name='state'),
url(r'^my_index/(?P<country_id>\d+)/state/$', 'my_App.views.country', name='country'),
- [Answer]-UnicodeDecodeError when using django forms
- [Answer]-Need to create a user application in python-Django framework where based on input data will insert or update in the database
- [Answer]-Appending render with decorator in Django
- [Answer]-Heroku deployment busted, operational error
- [Answer]-Pydev Django1.4 ImportError
Source:stackexchange.com