On Feb 22, 4:53 pm, Brian <bdele...@gmail.com> wrote:
> My experience level: basic. I'm not a developer by trade and do it as
> a hobby. I'm pretty familiar with basic web development--HTML, CSS and
> js. I have explored PHP and other technologies to improve my
> development. Now I've started developing using Django+App Engine
> Datastore. I've got an application to do various things working--
> submit data, delete data, edit data, view data, etc. Right now I'm
> stuck on something that seems like it should be relatively simple...
>
> On my index page I have a search form (along with data and other
> stuff). I've got it so the user can enter a search, select type, and
> then get data and other stuff on a new page. Form field IDs are
> id_search and id_type. Action is "/search/". On the results page I'd
> like the URL to include the search data so the user can bookmark this
> and open it at a later date. I've read various topics on the django
> approach to formatting URLs to make them more readable and to put
> thought into the best long-term approach. I haven't been able to
> figure out how to change the URL that shows up in the browser to
> include the search data. I'm pretty sure I can handle this bookmark
> URL through URLCONF once I get to that point. Please direct me to some
> reading to get me through this--I'm probably not using the right
> search terms for this topic when I google.
>
> Thanks

You probably want to send the search terms as GET parameters rather
than POST. This means that instead of being sent invisibly along with
the form submission, they are actually encoded in the URL:
/search/?search=search_term&type=search_type
You'll have seen these in, for example, the Django admin change_list
view when you filter or sort. Since they're part of the URL itself,
they can be bookmarked.

Luckily you don't have to do anything complicated to make this happen:
in your search form template, make sure you define the HTML form using
method="GET".
<form action="." method="GET">
... and, of course, in your view you manage the form data using
request.GET rather than request.POST. You don't have to do anything to
the URLconf to pass these through.

--
DR.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to