lundi 3 mars 2014

How do I pass the results of a user submitted html form to django urls?


Vote count:

0




I have a Django Url pattern for my search filter as follows:



url(r'^search/(?P.+)$', views.search, name='search'),



That way, if I call, say /search/1+Timothy, the url goes to my search view, which returns the results of my query - in this case, all entries in 1 Timothy. So far, so good.


In my page, I wanted to add a simple call to this search function. So, I thought, why not a simple form?



<FORM method='GET' action='/search/'>
<!-- Note: Calls /search?filter_range=entered_reference is handled in urls.py-->
<LABEL for="filter_range">Show References</LABEL>
<INPUT id='filter_range' name='filter_range' type='text' placeholder='search' value='' />
<INPUT type='submit' />
</FORM>


Which should be equal to a simple:



http://ift.tt/NohfJi


Problem is, I can't figure out how to specify that in the urls.py:



url(r'^search/\\?passage=(?P<filter_range>.+)$', views.search, name='search'),
url(r'^search/(?P<filter_range>.+)$', views.search, name='search'),


doesn't work, nor can I seem to figure out a regular expression that does. So, how do I get the output of the form in my template to callback to a url that urls.py can find?



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire