writing most common queries as model class method!

2022-11-11 Thread Amir Jamshidi
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?*


-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e58df10a-e5c0-40e8-8e0d-5439c04281d8n%40googlegroups.com.


Re: Salutation

2024-09-27 Thread Amir Jamshidi
Salam

On Fri, Sep 27, 2024 at 11:12 PM Sreedhar p  wrote:

> Hii
>
> On Sat, Sep 28, 2024, 00:32  wrote:
>
>> hi
>>
>> --
>> 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 django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CA%2BARzD80pkTOKygrz8YogMFK1WfTpXGdimcPQ4jGXVe0D18GqQ%40mail.gmail.com
>> 
>> .
>>
> --
> 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 django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CADzXRbdeAMfhfSdEc6Ykaxv88iBkOXxHFC5WOHq-AM3aoZ99Pw%40mail.gmail.com
> 
> .
>


-- 
___
Amir JamshidiJam
Computer Engineering at Shiraz University
4|\/|!|2_|_|

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAC-x6WZ4W9uRBnaG6yXP0UHCj2spxsH8T%2BciiONKTprecAr3Eg%40mail.gmail.com.