I am building a Django app that works with a text-heavy database, and it counts some predefined phrases within the text. It does not count the number of records that contain the phrases, but it counts the frequency within one record. And here is where i am stuck:
Django does count and find phrases if i add the string directly:
frequency = 'Search this text for me, please'.count('this text')
When i use this logic with a model Manager, "count" does not work, and gives the error:
Typeerror: count() takes 1 positional argument but 2 were given
This is my code in model.py
class MyModelManager(models.Manager):
def get_queryset(self):
qs = super(MyModelManager, self).get_queryset().values_list('mytext').count('this text')
return qs
class MyModel(models.Model):
mytext = models.TextField()
...
objects = MyModelManager()
Can you please suggest me how should i continue? Am i on the right track or should i apply a totally different approach to make this working? Thanks!