/ Published in: Django

Simula in Django i campi created e updated aggiornati automaticamente alla creazione e alla modifica del record (Versione 2 senza funzione save ridefinita)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
from django.db import models # Create your models here. class Timestamp(models.Model): created = models.DateTimeField(auto_now_add=True, editable=False) updated = models.DateTimeField(auto_now=True, auto_now_add=True, editable=False) class Meta: abstract = True class Example(Timestamp): name = models.CharField(max_length=255)
Comments
