Dariusz Krynicki
Dariusz Krynicki

Reputation: 2718

django search in db for similar entries my string name

I would like to build following app with Python + Django:

mydb: it is database of entries originally defined by me. new entry: a new entry with any name of it for example: John each entry has got some parameters for example: p1, p2, p3

when I add new entry I type in a box and while typing its name I search through mydb for all similar (similar name starting with J) entries.

for example: mydb has got following entries:

John Jade Jack Kate

while typing a new entry when i type J it lists Jade, Jack, John so it's got similar functionality as google search engine or here stackoverflow search for similar tags while defining a tag.

if I find exact entry in mydb than I choose it. if I do not find same entry in mydb I can define new entry with parameters p1, p2, p3.

I know at the moment how to creat a todo app with django so I can add new entries and edit them but I struggle with search funcionality as described below.

Could somebody point me to right direction what knowledge to gather, what examples to follow ?

I have found this old post dated 2010 but I am curious if there is anything better, newer: search form with django+python

I have some knowledge of Python, Django, PostgreSQL only at the moment.

Many thanks.

Upvotes: 0

Views: 498

Answers (2)

Lucas Moeskops
Lucas Moeskops

Reputation: 5443

You will have to learn some Javascript to learn how to interact with a search box on a page. You can write a django view to obtain the similar entries you need (it has to query the database). Make javascript call the django view (AJAX) to determine what entries to display.

Upvotes: 1

Luca
Luca

Reputation: 322

I think you would need Haystack to do db search. To achieve the interactive search effect, you would also need javascript or jQuery to do Ajax calls.

Upvotes: 0

Related Questions