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 

 

 

 

 

 

Sent from Mail for Windows 10

 

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

 

Then you should write a views.py function where you should use

query=request.GET[‘queer’]

Object_list=Post.objects.filter(title__icontains=query)

*same for the content If you want and then you should use union*

Return render(request,’search.html’,{ ‘object_list’:object_list,’query’:query})

 

Then in the sign.html use ur home.html or anything and write according to your requirement

 

You don’t need to use java

 

--

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+unsubscr...@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.

 

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5ec5630d.1c69fb81.1f3d5.4cfd%40mx.google.com.

Reply via email to