diff options
| author | Craig de Stigter <craig.destigter@koordinates.com> | 2014-05-29 10:26:57 +1200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-06-02 09:32:38 -0400 |
| commit | ce993efda876b19569267badb6af5fd0e80cdee3 (patch) | |
| tree | f5c4c8be1dc0ff7dd02ed52c4b856423c4bb00d8 /django | |
| parent | 5046c110cfbf5e867fec47c8c68677a76c9e1b68 (diff) | |
Fixed #22690 -- Added a check for proxy models containing fields.
Removed the FieldError raised by ModelBase.__new__ in this case.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/base.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py index b223764879..11dcb5ba3e 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -194,9 +194,6 @@ class ModelBase(type): base = parent if base is None: raise TypeError("Proxy model '%s' has no non-abstract model base class." % name) - if (new_class._meta.local_fields or - new_class._meta.local_many_to_many): - raise FieldError("Proxy model '%s' contains model fields." % name) new_class._meta.setup_proxy(base) new_class._meta.concrete_model = base._meta.concrete_model else: @@ -1047,6 +1044,7 @@ class Model(six.with_metaclass(ModelBase)): def check(cls, **kwargs): errors = [] errors.extend(cls._check_swappable()) + errors.extend(cls._check_model()) errors.extend(cls._check_managers(**kwargs)) if not cls._meta.swapped: errors.extend(cls._check_fields(**kwargs)) @@ -1095,6 +1093,21 @@ class Model(six.with_metaclass(ModelBase)): return errors @classmethod + def _check_model(cls): + errors = [] + if cls._meta.proxy: + if cls._meta.local_fields or cls._meta.local_many_to_many: + errors.append( + checks.Error( + "Proxy model '%s' contains model fields." % cls.__name__, + hint=None, + obj=None, + id='models.E017', + ) + ) + return errors + + @classmethod def _check_managers(cls, **kwargs): """ Perform all manager checks. """ |
