Ticket #10572: defer-inheritance.diff

File defer-inheritance.diff, 1008 bytes (added by Alex, 6 years ago)
  • tests/regressiontests/defer_regress/models.py

    diff --git a/tests/regressiontests/defer_regress/models.py b/tests/regressiontests/defer_regress/models.py
    index e2a5944..473f521 100644
    a b class Leaf(models.Model): 
    3030    def __unicode__(self):
    3131        return self.name
    3232
     33class Place(models.Model):
     34    name = models.CharField(max_length=50)
     35
     36    def __unicode__(self):
     37        return self.name
     38
     39class Restaurant(Place):
     40    serves_pizza = models.BooleanField()
     41
    3342__test__ = {"regression_tests": """
    3443Deferred fields should really be deferred and not accidentally use the field's
    3544default value just because they aren't passed to __init__.
    u'c1' 
    91100>>> Leaf.objects.select_related().only("child__name", "second_child__name")
    92101[<Leaf_Deferred_name_value: l1>]
    93102
     103>>> _ = Restaurant.objects.create(name="The Art of Pizza", serves_pizza=True)
     104>>> r = Restaurant.objects.defer('name').get()
     105>>> r.save()
     106
    94107"""
    95108}
Back to Top