I made an app I called developers forum where authenticated users can post something like question or code achievement and another can comment in form of answer.
I want to add a search functionality which was not covered in the tutorial.
I browsed out and found how I could add the search but the search results will be displayed to a designated urls created for the purpose. I want to be able to redirect the searcher to the exact post containing the keyword they have typed in the search form with the text highlighted. How can I achieve that... If you need any pieces of my code to be able to help me, be kind to ask me; I'll post a link to where you can find it.
Thanks in advance.
Hi if you want a search bar you need javascript which will do the dynamic stuff. Add an event listener to you <input type=”search”> of html and use “change” as the event. Then you need to insert and remove elements on the DOM based on the text in the search box. For more info ask on https://webchat.freenode.net/ in the #javascript.
Sent from Mail for Windows 10
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cdbf7038-480e-446f-aeac-e079ad575e47%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5ec559c3.1c69fb81.ccc5c.9d57%40mx.google.com.
Then you have a better option to learn react(a frontend framework for javascript). You cannot do dynamic stuff on the web without using javascript.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALcuGNv0LBJeQxZB04xyWCDvTgoo5zN82Nf_7bqpomAbQWwAFQ%40mail.gmail.com.
Javascript it that needs to be done dynamically otherwise redirect()
From: Ali Ahammad
Sent: 20 May 2020 22:32
To: Django users
Subject: Add search to my blog app
At first you should make search search template where you should put what and how you want display
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/277d37ed-188f-4ad1-960a-e4f5eceee3d0%40googlegroups.com.
Or one thing you can do w/o javascript, that is send a post request to the server through a form and then redirect to a view with a blog matching that search query.
Template:
<form method=”POST >
{{csrf_token}} //see the correct template tag
<input type=”search” name=”search>
<button type=”submit”>Submit<button>
</form>
Views:
def index(request):
if request.method ==”POST”:
search_query = request.POST[“search”]
//Suppose search query is blog_1
If search_query[-1] == 1:
return httpResponse(“blog1”)
return //default index.html
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cdbf7038-480e-446f-aeac-e079ad575e47%40googlegroups.com.