mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
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
This commit is contained in:
@@ -8,7 +8,7 @@ from django.db import models
|
||||
from django.db.models.fields.files import FieldFile
|
||||
from django.utils import unittest
|
||||
|
||||
from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanModel, BooleanModel, Document
|
||||
from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanModel, BooleanModel, Document, RenamedField
|
||||
|
||||
# If PIL available, do these tests.
|
||||
if Image:
|
||||
@@ -53,6 +53,15 @@ class BasicFieldTests(test.TestCase):
|
||||
f = models.fields.CharField()
|
||||
self.assertEqual(repr(f), '<django.db.models.fields.CharField>')
|
||||
|
||||
def test_field_name(self):
|
||||
"""
|
||||
Regression test for #14695: explicitly defined field name overwritten
|
||||
by model's attribute name.
|
||||
"""
|
||||
instance = RenamedField()
|
||||
self.assertTrue(hasattr(instance, 'get_fieldname_display'))
|
||||
self.assertFalse(hasattr(instance, 'get_modelname_display'))
|
||||
|
||||
class DecimalFieldTests(test.TestCase):
|
||||
def test_to_python(self):
|
||||
f = models.DecimalField(max_digits=4, decimal_places=2)
|
||||
|
||||
Reference in New Issue
Block a user