V
V
vladidik2020-08-10 13:49:19
Django
vladidik, 2020-08-10 13:49:19

How to check if a post is duplicate in django database?

Good afternoon everyone, I would like to know how to implement a check for a duplicate record or post. Let's say I have a post where the Category, Author Name, Title is indicated, and I need to check if all these values ​​​​are duplicated again in the same post, do not tell me where to dig, maybe there are ready-made applications? Or has anyone else come across this situation.
I understand that I have to write a loop in the view that will go through all the data in the database, and check them for the similarity of the entered data from the form, like if category and author and name == data from the form, then it gives an error if at least one of values ​​do not match, then welcome to the database (Here Category = Detective, Author = Jack London, Name = Sherlock Holmes, well, let's say if I enter exactly the same data into the form, it will give an error. If I enter Detective, Jack London and Name for example Anna Karenina, he will enter this data into the database)
Thank you for any help. Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tikhonov, 2020-08-10
@vladidik

Usually a unique index is simply hung. If you need to compare a straight long text, then you can calculate the checksum. If "fuzzy search" is needed, it's probably already a full-text search engine that needs to be screwed on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question