summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-08-13 11:53:42 +0000
committerJannis Leidel <jannis@leidel.info>2011-08-13 11:53:42 +0000
commit1abafe696e44522e8d71c11a53501aeb70a75d38 (patch)
tree82b395471aad8e003e9feb2e71c00b44a863a859 /django
parentc0a4c04e2a639a03726a205b2f8f8a637ea511bc (diff)
Fixed #14695 -- Stopped model fields from incorrectly overwriting the field name during model initialization if it was already passed as a keyword argument. Thanks, erikrose and willhardy.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16614 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/db/models/fields/__init__.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index b786b7bf11..b9cc64ce3a 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -220,15 +220,16 @@ class Field(object):
except KeyError:
return None
+ @property
def unique(self):
return self._unique or self.primary_key
- unique = property(unique)
def set_attributes_from_name(self, name):
- self.name = name
+ if not self.name:
+ self.name = name
self.attname, self.column = self.get_attname_column()
- if self.verbose_name is None and name:
- self.verbose_name = name.replace('_', ' ')
+ if self.verbose_name is None and self.name:
+ self.verbose_name = self.name.replace('_', ' ')
def contribute_to_class(self, cls, name):
self.set_attributes_from_name(name)