Hi,
I tried to write a classmothods/ instance method in a Model in order to run most common query from the model but got errors like below :
""AttributeError: Manager isn't accessible via ... instances""
example code:
class Profile(model.Model):
name = model.Charfield(...)
address = model.Charfield(...)
....
@classmethod
def count_of_users(cls):
return cls.objects.all() #example query
def all_users(self):
return self.objects....
My purpose is to have most common and important queries in a method to be called within application. (Its a good way for documenting most common queries as well).What is the best practice for this case?