How can I conditionally only log something if it's a certain Class?
Posted
by BryanWheelock
on Stack Overflow
See other posts from Stack Overflow
or by BryanWheelock
Published on 2010-04-14T21:18:03Z
Indexed on
2010/04/14
21:23 UTC
Read the original article
Hit count: 403
Something like this:
if self.class == "User": logging.debug("%s non_pks were found" % (str(len(non_pks))) )
In [2]: user = User.objects.get(pk=1)
In [3]: user.class Out[3]:
In [4]: if user.class == 'django.contrib.auth.models.User': print "yes" ...:
In [5]: user.class == 'django.contrib.auth.models.User' Out[5]: False
In [6]: user.class == 'User' Out[6]: False
In [7]: user.class == "" Out[7]: False
© Stack Overflow or respective owner