Ticket #24539: 24539-test.diff

File 24539-test.diff, 1.0 KB (added by Tim Graham, 10 years ago)
  • tests/model_inheritance/models.py

    diff --git a/tests/model_inheritance/models.py b/tests/model_inheritance/models.py
    index 3245c71..650a6a3 100644
    a b class Base(models.Model):  
    186186
    187187class SubBase(Base):
    188188    sub_id = models.IntegerField(primary_key=True)
     189
     190
     191# auto_now_add/auto_now in abstract model
     192class Timestamps(models.Model):
     193    created = models.DateTimeField(auto_now_add=True)
     194    updated = models.DateTimeField(auto_now=True)
     195
     196    class Meta:
     197        abstract = True
     198
     199
     200class Product(Timestamps):
     201    name = models.CharField(max_length=100, primary_key=True)
  • new file tests/model_inheritance/test_auto_now.py

    diff --git a/tests/model_inheritance/test_auto_now.py b/tests/model_inheritance/test_auto_now.py
    new file mode 100644
    index 0000000..886391a
    - +  
     1from django.test import TestCase
     2
     3from .models import Product
     4
     5
     6class TestAutoNow(TestCase):
     7    def test_model_save(self):
     8        Product(name='foo').save()
     9        Product(name='foo').save()
Back to Top