django 2 - How do I make search box?

64 views
Skip to first unread message

Carl Brubaker

unread,
Jan 23, 2018, 6:34:48 AM1/23/18
to Django users
I am trying to make a search field in a template and connect it back to my database so I can "find" stuff.

I found this in the django docs:

>>> Author.objects.filter(name__unaccent__icontains='Helen')
[<Author: Helen Mirren>, <Author: Helena Bonham Carter>, <Author: Hélène Joy>]

which is helpful, but I'm having trouble connecting to my template:

<input type="search" />

I'm not sure what to call my variable or how to integrate it into models. All of the existing stuff I can find is django 1.

Thanks!

Ozzy Walsh

unread,
Jan 24, 2018, 7:30:23 AM1/24/18
to Django users

Ozzy Walsh

unread,
Jan 24, 2018, 7:37:23 PM1/24/18
to Django users
Also, by the sounds of your question, you haven't worked through the tutorial.
Please take the time to do so. It might take you around an hour or whatever but gives an extremely good overview of everything you need to build stuff in Django.
I'm sure your dying to work on your big idea, but it pays to take the time to get the basics down. Tutorial here: https://docs.djangoproject.com/en/2.0/intro/#


On Tuesday, January 23, 2018 at 11:34:48 AM UTC, Carl Brubaker wrote:

harsh sharma

unread,
Jan 25, 2018, 4:05:37 AM1/25/18
to Django users
i think you can create a form for this and integrate in your template. through which u can search in your database . and for more details check 

Carl Brubaker

unread,
Jan 25, 2018, 7:51:06 AM1/25/18
to Django users
I did go through the tutorial. I'm reading through the the forms section of the documentation now. I'm more of a visual learner, so sometimes I have to read things 10 times til it makes sense. Thanks for your help!

Jani Tiainen

unread,
Jan 25, 2018, 8:05:09 AM1/25/18
to django...@googlegroups.com

Hi,

If you feel that Django official tutorial was too packed, Django Girls do have excellent tutorial that goes things in more depth: https://tutorial.djangogirls.org/en/


On 25.1.2018 14.51, Carl Brubaker wrote:
I did go through the tutorial. I'm reading through the the forms section of the documentation now. I'm more of a visual learner, so sometimes I have to read things 10 times til it makes sense. Thanks for your help!
--
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 post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7e582b5d-23b7-43fc-a6f0-3902c26bdf46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
Jani Tiainen
Reply all
Reply to author
Forward
0 new messages