Changeset 2506
- Timestamp:
- 03/08/06 14:59:00 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/django/db/models/base.py
r2487 r2506 1 1 import django.db.models.manipulators 2 2 import django.db.models.manager 3 from django.db.models.fields import AutoField, ImageField 3 from django.db.models.fields import AutoField, ImageField, FieldDoesNotExist 4 4 from django.db.models.fields.related import OneToOne, ManyToOne 5 5 from django.db.models.related import RelatedObject … … 57 57 for parent in new_class._meta.parents: 58 58 for field in parent._meta.fields: 59 field.contribute_to_class(new_class, field.name) 59 # Only add parent fields if they aren't defined for this class. 60 try: 61 new_class._meta.get_field(field.name) 62 except FieldDoesNotExist: 63 field.contribute_to_class(new_class, field.name) 60 64 61 65 new_class._prepare() django/branches/magic-removal/tests/modeltests/model_inheritance/models.py
r2504 r2506 20 20 return "%s the restaurant" % self.name 21 21 22 class ItalianRestaurant(Restaurant): 23 serves_gnocchi = models.BooleanField() 24 25 def __repr__(self): 26 return "%s the italian restaurant" % self.name 27 22 28 API_TESTS = """ 23 29 # Make sure Restaurant has the right fields in the right order. … … 25 31 ['id', 'name', 'address', 'serves_hot_dogs', 'serves_pizza'] 26 32 33 # Make sure ItalianRestaurant has the right fields in the right order. 34 >>> [f.name for f in ItalianRestaurant._meta.fields] 35 ['id', 'name', 'address', 'serves_hot_dogs', 'serves_pizza', 'serves_gnocchi'] 36 27 37 """
