Samuele Mattiuzzo
Samuele Mattiuzzo

Reputation: 11048

Django forms: submission with mixed requests (get and post)

for seo related reason in my project i have to trap certain search parameters within the url for the "beautiful url" thing.

The advanced search is composed by 7 parameters, 3 of which are location-related and are the ones interesting our seo consultant.

So, now i'm a bit confused. It's been a while since i started using django professionally, but never had to face an issue like this. Basically, the final url structure must be something like this:

/Italy/Lombardy/Milan/?price=100&miles=10&last_posted=2

and my urls.py is

'/(?P<country>\w+)/(?P<zone>\w+)/(?P<city>\w+)/$', SearchView.as_view()

now, what i'm not sure about is how should i specify my request in the form method to be able to use that exact url schema? POST or GET? And how can i compose the url for the "action" attribute dynamically while the user types? Is this even the correct solution? I'm really confused about it, any help would be really appreciated! Thanks!

Upvotes: 0

Views: 342

Answers (1)

akonsu
akonsu

Reputation: 29576

you will have to change the action field of the form using script, yes. and set the method to GET, and include in the form only the fields appearing in the query string.

Upvotes: 1

Related Questions