I've tried to set up a Django model with a python property, like so:
class Post(models.Model):
_summary = models.TextField(blank=True)
body = models.TextField()
@property
def summary(self):
if self._summary:
return self._summary
else:
return self.body
@summary.setter
def summary(self, value):
self._summary = value
@summary.deleter
def summary(self):
self._summary = ''
So far so good, and in the console I can interact with the summary property just fine. But when I try to do anything Django-y with this, like Post(title="foo", summary="bar")
, it throws a fit. Is there any way to get Django to play nice with Python properties?