Changeset 7143
- Timestamp:
- 02/21/08 22:58:53 (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/queryset-refactor/django/db/models/options.py
r7142 r7143 60 60 del meta_attrs['__doc__'] 61 61 for attr_name in DEFAULT_NAMES: 62 setattr(self, attr_name, meta_attrs.pop(attr_name, getattr(self, attr_name))) 62 if attr_name in meta_attrs: 63 setattr(self, attr_name, meta_attrs.pop(attr_name)) 64 elif hasattr(self.meta, attr_name): 65 setattr(self, attr_name, getattr(self.meta, attr_name)) 63 66 64 67 # unique_together can be either a tuple of tuples, or a single django/branches/queryset-refactor/tests/modeltests/model_inheritance/models.py
r7142 r7143 47 47 class Meta: 48 48 abstract = True 49 ordering = ['-rating'] 49 50 50 51 class Restaurant(Place, Rating): 51 52 serves_hot_dogs = models.BooleanField() 52 53 serves_pizza = models.BooleanField() 54 55 class Meta(Rating.Meta): 56 db_table = 'my_restaurant' 53 57 54 58 def __unicode__(self): … … 125 129 126 130 # Test the constructor for ItalianRestaurant. 127 >>> ir = ItalianRestaurant(name='Ristorante Miron', address='1234 W. Elm', serves_hot_dogs=False, serves_pizza=False, serves_gnocchi=True )131 >>> ir = ItalianRestaurant(name='Ristorante Miron', address='1234 W. Elm', serves_hot_dogs=False, serves_pizza=False, serves_gnocchi=True, rating=4) 128 132 >>> ir.save() 129 133 … … 134 138 >>> [f.name for f in ItalianRestaurant._meta.fields] 135 139 ['id', 'name', 'address', 'place_ptr', 'rating', 'serves_hot_dogs', 'serves_pizza', 'restaurant_ptr', 'serves_gnocchi'] 140 >>> Restaurant._meta.ordering 141 ['-rating'] 136 142 137 143 # Even though p.supplier for a Place 'p' (a parent of a Supplier), a Restaurant … … 199 205 200 206 >>> Restaurant.objects.filter(provider__name__contains="Chickens") 201 [<Restaurant: Demon Dogs the restaurant>, <Restaurant: Ristorante Mironthe restaurant>]207 [<Restaurant: Ristorante Miron the restaurant>, <Restaurant: Demon Dogs the restaurant>] 202 208 >>> ItalianRestaurant.objects.filter(provider__name__contains="Chickens") 203 209 [<ItalianRestaurant: Ristorante Miron the italian restaurant>]
