Return to Snippet

Revision: 32649
at October 1, 2010 04:09 by munkypot


Initial Code
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)

Initial URL

                                

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

Initial Title
Timestamp Inherit Model (Versione 2)

Initial Tags
database, date, django

Initial Language
Django