You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: I removed the NO_LOGGING_MSG_ATTR as I did not need that, correspondingly I made changes and removed the because variable in the remaining functions too.
I am using DRF view classes which have a few arguments.
The func evaluates to be one of the argument and not the class itself for which reason, the getattr is not able to retrieve NO_LOGGING_ATTR.
My use case is this:
@no_logging()
class MapImageViewSet(arg1, RetrieveModelMixin, UpdateModelMixin):
The func in above should_log_route class evaluates to be <function RetrieveModelMixin.retrieve at 0x7f8986b91940>.
Can someone tell if I am using the no_logging decorator correctly or there is some error in evaluating the func in the should_log_route function?
Thanks
EDIT:
So, I figured out the class we are decorating the @no_logging func with should be a view class.
And view.cls gets us the complete class name so we can retrieve the attribute set by our no_logging can be retrieved by using:
Hi All,
Could anyone tell me how do I use the no_logging decorator?
I am not able to retrieve the correct function name from the following piece of code:
And my no_logging function looks like this:
Note: I removed the NO_LOGGING_MSG_ATTR as I did not need that, correspondingly I made changes and removed the because variable in the remaining functions too.
I am using DRF view classes which have a few arguments.
The func evaluates to be one of the argument and not the class itself for which reason, the getattr is not able to retrieve NO_LOGGING_ATTR.
My use case is this:
The func in above should_log_route class evaluates to be <function RetrieveModelMixin.retrieve at 0x7f8986b91940>.
Can someone tell if I am using the no_logging decorator correctly or there is some error in evaluating the func in the should_log_route function?
Thanks
EDIT:
So, I figured out the class we are decorating the @no_logging func with should be a view class.
And view.cls gets us the complete class name so we can retrieve the attribute set by our no_logging can be retrieved by using:
no_logging = getattr(view.cls, NO_LOGGING_ATTR, False)
The above is true for DRF use cases.
Didn't understand why are we trying to retrieve the method and stuff.
Any explanation is greatly appreciated.
The text was updated successfully, but these errors were encountered: