24👍
You can also try __repr__
and __str__
for your logging/debugging purposes. It is possible (at least it should be this way) that your logger/debugger uses repr( object )
to log your objects.
👤Ski
8👍
Use properties
class SomeThing( models.Model ):
foo=
bar=
baz=
def __unicode__( self ):
return "{0} {1}".format( self.foo, self.bar )
@property
def details( self ):
return repr( dict( foo=self.foo, bar=self.bar, baz=self.baz ) )
Now you can log someObject.details
- Generate update query using django orm
- Changing model field within the Django Shell
- Running django in virtualenv – ImportError: No module named django.core.management?
- How to go from a Model base to derived class in Django?
- Django: Implementing a referral program
Source:stackexchange.com