Friday, October 11, 2019

Re: Save partial state of a page when reloading

hi,

I think It's not a django problem, it's a classic web developing problem.

Http is stateless, if you want to 'save' something, you need to use 
1. URL param like the 'q=soccer'.
2. Use cookie/session.

I think your problem can be solved by one of the methods below:
1. Use ajax to do the search, and use javascript to update the search result, so the page will not be reload when doing search.
2. Put the search box and category check-boxes in one form, when the user submit to search, the browser will also submit the categories check boxes, so you know what the user selected, you can select them again in the response html.
3. Use javascript to remember what category the user selected, and render the selection when the page reloaded.

On Sat, Oct 12, 2019 at 5:07 AM Robert Levasseur <rel1071@g.rit.edu> wrote:
Hi, 

I'm very new to Django so this might be a silly question, but I'm having an issue with the filter functionality on my site's search page. I am using the django-haystack module to interface with the Whoosh search engine, and it functions by reloading the page while sending the query as a GET parameter. This means when someone runs the search, say for soccer, on the site it loads the page with a url /search/?q=soccer 
On the same page I have a from with a bunch of category check-boxes that I would like to use to filter the search results. I run into the problem however that if I submit the form and reload the page it does not remember the search text, and If I run the search and reload the page it does not remember which categories were selected.

Is there a way in Django for me to pull both of these pieces of information and mess around with them in views.py, while maintaining the state of the category form and search box? Sorry if this is a strange question, and thanks for any help!

Regards,
R. Eli

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a25b09a0-be13-4f18-8752-ea1bb6b9f1a0%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABexzmhcqSGOs6NgkEzZAS7uL4URZRqV6X-sjqPQDBK9cH7nqQ%40mail.gmail.com.

No comments:

Post a Comment