Hi,
I am trying to migrate my mysql application into django orm. I need help
converting my sql statements into it. Here are my models
class SearchableText(models.Model):
searchable_text = models.TextField()
class SearchTerm(models.Model):
searchabletext = models.ForeignKey(SearchableText, on_delete=models.CASCADE)
term = models.CharField(max_length=100)
This is basically a table to store some textual information, and another
table to use as index of searchable terms.
Consider it like this
SearchableText
id searchable_text
1 "this is text"
2 "this is another text"
SearchTerm
id searchable_text term
1 1 this
2 1 is
3 1 text
4 2 this
5 2 is
6 2 another
7 2 text
I would normally do a sql query like this;
Select SearchableText.*
Right Join SearchTerm on SearchTerm.searchable_text = SearchableText.id
Where term in ("is","another")
group by SearchTerm.searchable_text ORDER BY COUNT(SearchTerm.term ) DESC
LIMIT
Right now, I don't even know where to start writing a complex sql like this
using django-orm so any help is appreciated.
--
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 [email protected].
To post to this group, send email to [email protected].
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/c6481fa3-1d35-4957-b70e-3d9912715546%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.