7👍
Proper version to work is: (attention to last line self.message.save()
)
class Message(models.Model):
updated = models.DateTimeField(auto_now = True)
...
class Attachment(models.Model):
updated = models.DateTimeField(auto_now = True)
message = models.ForeignKey(Message)
def save(self):
super(Attachment, self).save()
self.message.save()
- DjangoRestFramework HTTPS Links With Routers and Viewsets
- Redirect from Generic View DetailView in Django
- Best way of linking to a page in Django
- How to print pretty JSON on a html page from a django template?
- Django remove user from all groups
1👍
DateTime fields with auto_now are automatically updated upon calling save()
, so you do not need to update them manually. Django will do this work for you.
- How to obtain a plain text Django error page
- Django 1.4 – bulk_create with a list
- Django – inline – Search for existing record instead of adding a new one
- Django MySQL distinct query for getting multiple values
- Django application 504 error after saving model
Source:stackexchange.com