Fix proxy model handling.

Previously, proxy models would receive transaltion fields twice, as inspeceted by model._meta.get_fields_with_model()
This commit is contained in:
Jacek Tomaszewski 2013-11-09 16:18:47 +01:00
parent 410888517e
commit 42128390e6

View file

@ -74,7 +74,7 @@ class TranslationOptions(with_metaclass(FieldsAggregationMetaClass, object)):
"""
Update with options from a superclass.
"""
if other.model._meta.abstract or self.model._meta.proxy:
if other.model._meta.abstract:
self.local_fields.update(other.local_fields)
self.fields.update(other.fields)
@ -123,6 +123,11 @@ def add_translation_fields(model, opts):
model.add_to_class(localized_field_name, translation_field)
opts.add_translation_field(field_name, translation_field)
# Rebuild information about parents fields. If there are opts.local_fields, field cache would be
# invalidated (by model._meta.add_field() function). Otherwise, we need to do it manually.
if len(opts.local_fields) == 0:
model._meta._fill_fields_cache()
def add_manager(model):
"""