| 20 | | def save(self, *args, **kwargs): |
| 21 | | """Ensure created_at and updated_at are identical on creation""" |
| 22 | | if self._state.adding: |
| 23 | | now = timezone.now() |
| 24 | | if not self.created_at: |
| 25 | | self.created_at = now |
| 26 | | self.updated_at = self.created_at |
| 27 | | super().save(*args, **kwargs) |
| | 20 | def save(self, *args, **kwargs): |
| | 21 | """Ensure created_at and updated_at are identical on creation""" |
| | 22 | now = timezone.now() |
| | 23 | if self._state.adding: |
| | 24 | # On creation, set both to the same timestamp |
| | 25 | if not self.created_at: |
| | 26 | self.created_at = now |
| | 27 | self.updated_at = self.created_at |
| | 28 | else: |
| | 29 | # On update, only touch updated_at |
| | 30 | self.updated_at = now |
| | 31 | super().save(*args, **kwargs) |