public
Created

  • Download Gist
foo.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
diff --git a/django/db/models/base.py b/django/db/models/base.py
index ce3f095..1d3bb12 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -360,12 +360,12 @@ class Model(six.with_metaclass(ModelBase)):
# The reason for the kwargs check is that standard iterator passes in by
# args, and instantiation for iteration is 33% faster.
args_len = len(args)
- if args_len > len(self._meta.concrete_fields):
+ if args_len > len(self._meta.fields):
# Daft, but matches old exception sans the err msg.
raise IndexError("Number of args exceeds number of fields")
if not kwargs:
- fields_iter = iter(self._meta.concrete_fields)
+ fields_iter = iter(self._meta.fields)
# The ordering of the zip calls matter - zip throws StopIteration
# when an iter throws it. So if the first iter throws it, the second
# is *not* consumed. We rely on this, so don't change the order
@@ -564,7 +564,7 @@ class Model(six.with_metaclass(ModelBase)):
# automatically do a "update_fields" save on the loaded fields.
elif not force_insert and self._deferred and using == self._state.db:
field_names = set()
- for field in self._meta.concrete_fields:
+ for field in self._meta.fields:
if not field.primary_key and not hasattr(field, 'through'):
field_names.add(field.attname)
deferred_fields = [
@@ -650,7 +650,7 @@ class Model(six.with_metaclass(ModelBase)):
for a single table.
"""
meta = cls._meta
- non_pks = [f for f in meta.local_concrete_fields if not f.primary_key]
+ non_pks = [f for f in meta.local_fields if not f.primary_key]
if update_fields:
non_pks = [f for f in non_pks
@@ -682,7 +682,7 @@ class Model(six.with_metaclass(ModelBase)):
**{field.name: getattr(self, field.attname)}).count()
self._order = order_value
- fields = meta.local_concrete_fields
+ fields = meta.local_fields
if not pk_set:
fields = [f for f in fields if not isinstance(f, AutoField)]
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index dec2e2d..50ba8e0 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -424,10 +424,7 @@ class Field(object):
def contribute_to_class(self, cls, name, virtual_only=False):
self.set_attributes_from_name(name)
self.model = cls
- if virtual_only:
- cls._meta.add_virtual_field(self)
- else:
- cls._meta.add_field(self)
+ cls._meta.add_field(self)
if self.choices:
setattr(cls, 'get_%s_display' % self.name,
curry(cls._get_FIELD_display, field=self))
diff --git a/django/forms/models.py b/django/forms/models.py
index 6d9a567..e091a0f 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -119,7 +119,7 @@ def model_to_dict(instance, fields=None, exclude=None):
from django.db.models.fields.related import ManyToManyField
opts = instance._meta
data = {}
- for f in opts.concrete_fields + opts.many_to_many:
+ for f in opts.fields + opts.many_to_many:
if not f.editable:
continue
if fields and not f.name in fields:
@@ -174,7 +174,7 @@ def fields_for_model(model, fields=None, exclude=None, widgets=None,
field_list = []
ignored = []
opts = model._meta
- for f in sorted(opts.concrete_fields + opts.many_to_many):
+ for f in sorted(opts.fields + opts.many_to_many):
if not f.editable:
continue
if fields is not None and not f.name in fields:

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.