Wednesday, June 17, 2015

Get the name of the method in QuerySetAPI


I am trying to log overridden calls to QuerySetAPI.  Say I am calling Example.objects.filter(id=1)and I have following code in Models.py

objects = MyManager()

and in MyManager I have-

class MyManager(Manager):      def get_query_set(self):         # logging stuff I am doing         return super(MyManager, self).get_query_set()

How do I get the method name such as filter,all,get_or_create_object (i.e. filter here) in MyManager->get_query_set()? Is there a way to do that without using inspect stack()?

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7d723589-23d8-423c-8a6f-e6f9dca4aa08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment