Timestamp Inherit Model (Versione 2)


/ Published in: Django
Save to your folder(s)

Simula in Django i campi created e updated aggiornati automaticamente alla creazione e alla modifica del record (Versione 2 senza funzione save ridefinita)


Copy this code and paste it in your HTML
  1. from django.db import models
  2.  
  3. # Create your models here.
  4. class Timestamp(models.Model):
  5. created = models.DateTimeField(auto_now_add=True, editable=False)
  6. updated = models.DateTimeField(auto_now=True, auto_now_add=True, editable=False)
  7.  
  8. class Meta:
  9. abstract = True
  10.  
  11. class Example(Timestamp):
  12. name = models.CharField(max_length=255)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.