Refs #26154 -- Removed deprecated CommaSeparatedIntegerField.
This commit is contained in:
parent
bc3540ce2c
commit
bcf3532ede
|
@ -135,7 +135,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||
'BinaryField': 'longblob',
|
||||
'BooleanField': 'bool',
|
||||
'CharField': 'varchar(%(max_length)s)',
|
||||
'CommaSeparatedIntegerField': 'varchar(%(max_length)s)',
|
||||
'DateField': 'date',
|
||||
'DateTimeField': 'datetime',
|
||||
'DecimalField': 'numeric(%(max_digits)s, %(decimal_places)s)',
|
||||
|
|
|
@ -89,7 +89,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||
'BinaryField': 'BLOB',
|
||||
'BooleanField': 'NUMBER(1)',
|
||||
'CharField': 'NVARCHAR2(%(max_length)s)',
|
||||
'CommaSeparatedIntegerField': 'VARCHAR2(%(max_length)s)',
|
||||
'DateField': 'DATE',
|
||||
'DateTimeField': 'TIMESTAMP',
|
||||
'DecimalField': 'NUMBER(%(max_digits)s, %(decimal_places)s)',
|
||||
|
|
|
@ -76,7 +76,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||
'BinaryField': 'bytea',
|
||||
'BooleanField': 'boolean',
|
||||
'CharField': 'varchar(%(max_length)s)',
|
||||
'CommaSeparatedIntegerField': 'varchar(%(max_length)s)',
|
||||
'DateField': 'date',
|
||||
'DateTimeField': 'timestamp with time zone',
|
||||
'DecimalField': 'numeric(%(max_digits)s, %(decimal_places)s)',
|
||||
|
|
|
@ -73,7 +73,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||
'BinaryField': 'BLOB',
|
||||
'BooleanField': 'bool',
|
||||
'CharField': 'varchar(%(max_length)s)',
|
||||
'CommaSeparatedIntegerField': 'varchar(%(max_length)s)',
|
||||
'DateField': 'date',
|
||||
'DateTimeField': 'datetime',
|
||||
'DecimalField': 'decimal',
|
||||
|
|
|
@ -1090,27 +1090,18 @@ class CharField(Field):
|
|||
class CommaSeparatedIntegerField(CharField):
|
||||
default_validators = [validators.validate_comma_separated_integer_list]
|
||||
description = _("Comma-separated integers")
|
||||
system_check_deprecated_details = {
|
||||
system_check_removed_details = {
|
||||
'msg': (
|
||||
'CommaSeparatedIntegerField has been deprecated. Support '
|
||||
'for it (except in historical migrations) will be removed '
|
||||
'in Django 2.0.'
|
||||
'CommaSeparatedIntegerField is removed except for support in '
|
||||
'historical migrations.'
|
||||
),
|
||||
'hint': (
|
||||
'Use CharField(validators=[validate_comma_separated_integer_list]) instead.'
|
||||
'Use CharField(validators=[validate_comma_separated_integer_list]) '
|
||||
'instead.'
|
||||
),
|
||||
'id': 'fields.W901',
|
||||
'id': 'fields.E901',
|
||||
}
|
||||
|
||||
def formfield(self, **kwargs):
|
||||
defaults = {
|
||||
'error_messages': {
|
||||
'invalid': _('Enter only digits separated by commas.'),
|
||||
}
|
||||
}
|
||||
defaults.update(kwargs)
|
||||
return super(CommaSeparatedIntegerField, self).formfield(**defaults)
|
||||
|
||||
|
||||
class DateTimeCheckMixin(object):
|
||||
|
||||
|
|
|
@ -174,7 +174,10 @@ Model fields
|
|||
(except in historical migrations) will be removed in Django 1.9. *This check
|
||||
appeared in Django 1.7 and 1.8*.
|
||||
* **fields.W901**: ``CommaSeparatedIntegerField`` has been deprecated. Support
|
||||
for it (except in historical migrations) will be removed in Django 2.0.
|
||||
for it (except in historical migrations) will be removed in Django 2.0. *This
|
||||
check appeared in Django 1.10 and 1.11*.
|
||||
* **fields.E901**: ``CommaSeparatedIntegerField`` is removed except for support
|
||||
in historical migrations.
|
||||
|
||||
File fields
|
||||
~~~~~~~~~~~
|
||||
|
|
|
@ -584,8 +584,7 @@ Character fields
|
|||
Any fields that are stored with ``VARCHAR`` column types have their
|
||||
``max_length`` restricted to 255 characters if you are using ``unique=True``
|
||||
for the field. This affects :class:`~django.db.models.CharField`,
|
||||
:class:`~django.db.models.SlugField` and
|
||||
:class:`~django.db.models.CommaSeparatedIntegerField`.
|
||||
:class:`~django.db.models.SlugField`.
|
||||
|
||||
``TextField`` limitations
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
@ -480,21 +480,6 @@ The default form widget for this field is a :class:`~django.forms.TextInput`.
|
|||
of. Refer to the :ref:`MySQL database notes <mysql-collation>` for
|
||||
details.
|
||||
|
||||
``CommaSeparatedIntegerField``
|
||||
------------------------------
|
||||
|
||||
.. class:: CommaSeparatedIntegerField(max_length=None, **options)
|
||||
|
||||
.. deprecated:: 1.9
|
||||
|
||||
This field is deprecated in favor of :class:`~django.db.models.CharField`
|
||||
with ``validators=[``\ :func:`validate_comma_separated_integer_list
|
||||
<django.core.validators.validate_comma_separated_integer_list>`\ ``]``.
|
||||
|
||||
A field of integers separated by commas. As in :class:`CharField`, the
|
||||
:attr:`~CharField.max_length` argument is required and the note about database
|
||||
portability mentioned there should be heeded.
|
||||
|
||||
``DateField``
|
||||
-------------
|
||||
|
||||
|
|
|
@ -342,3 +342,6 @@ these features.
|
|||
* The ``shell --plain`` option is removed.
|
||||
|
||||
* The ``django.core.urlresolvers`` module is removed.
|
||||
|
||||
* ``CommaSeparatedIntegerField`` is removed, except for support in historical
|
||||
migrations.
|
||||
|
|
|
@ -70,8 +70,6 @@ Model field Form field
|
|||
:attr:`~django.forms.CharField.empty_value`
|
||||
set to ``None`` if ``null=True``.
|
||||
|
||||
:class:`CommaSeparatedIntegerField` :class:`~django.forms.CharField`
|
||||
|
||||
:class:`DateField` :class:`~django.forms.DateField`
|
||||
|
||||
:class:`DateTimeField` :class:`~django.forms.DateTimeField`
|
||||
|
|
|
@ -18,7 +18,6 @@ class CaseTestModel(models.Model):
|
|||
big_integer = models.BigIntegerField(null=True)
|
||||
binary = models.BinaryField(default=b'')
|
||||
boolean = models.BooleanField(default=False)
|
||||
comma_separated_integer = models.CommaSeparatedIntegerField(max_length=100, default='')
|
||||
date = models.DateField(null=True, db_column='date_field')
|
||||
date_time = models.DateTimeField(null=True)
|
||||
decimal = models.DecimalField(max_digits=2, decimal_places=1, null=True, db_column='decimal_field')
|
||||
|
|
|
@ -667,20 +667,6 @@ class CaseExpressionTests(TestCase):
|
|||
transform=attrgetter('integer', 'boolean')
|
||||
)
|
||||
|
||||
def test_update_comma_separated_integer(self):
|
||||
CaseTestModel.objects.update(
|
||||
comma_separated_integer=Case(
|
||||
When(integer=1, then=Value('1')),
|
||||
When(integer=2, then=Value('2,2')),
|
||||
default=Value(''),
|
||||
),
|
||||
)
|
||||
self.assertQuerysetEqual(
|
||||
CaseTestModel.objects.all().order_by('pk'),
|
||||
[(1, '1'), (2, '2,2'), (3, ''), (2, '2,2'), (3, ''), (3, ''), (4, '')],
|
||||
transform=attrgetter('integer', 'comma_separated_integer')
|
||||
)
|
||||
|
||||
def test_update_date(self):
|
||||
CaseTestModel.objects.update(
|
||||
date=Case(
|
||||
|
|
|
@ -50,7 +50,6 @@ class ColumnTypes(models.Model):
|
|||
null_bool_field = models.NullBooleanField()
|
||||
char_field = models.CharField(max_length=10)
|
||||
null_char_field = models.CharField(max_length=10, blank=True, null=True)
|
||||
comma_separated_int_field = models.CommaSeparatedIntegerField(max_length=99)
|
||||
date_field = models.DateField()
|
||||
date_time_field = models.DateTimeField()
|
||||
decimal_field = models.DecimalField(max_digits=6, decimal_places=1)
|
||||
|
|
|
@ -60,7 +60,6 @@ class InspectDBTestCase(TestCase):
|
|||
if not connection.features.interprets_empty_strings_as_nulls:
|
||||
assertFieldType('char_field', "models.CharField(max_length=10)")
|
||||
assertFieldType('null_char_field', "models.CharField(max_length=10, blank=True, null=True)")
|
||||
assertFieldType('comma_separated_int_field', "models.CharField(max_length=99)")
|
||||
assertFieldType('email_field', "models.CharField(max_length=254)")
|
||||
assertFieldType('file_field', "models.CharField(max_length=100)")
|
||||
assertFieldType('file_path_field', "models.CharField(max_length=100)")
|
||||
|
|
|
@ -29,12 +29,11 @@ class DeprecatedFieldsTests(SimpleTestCase):
|
|||
model = CommaSeparatedIntegerModel()
|
||||
self.assertEqual(
|
||||
model.check(),
|
||||
[checks.Warning(
|
||||
'CommaSeparatedIntegerField has been deprecated. Support '
|
||||
'for it (except in historical migrations) will be removed '
|
||||
'in Django 2.0.',
|
||||
[checks.Error(
|
||||
'CommaSeparatedIntegerField is removed except for support in '
|
||||
'historical migrations.',
|
||||
hint='Use CharField(validators=[validate_comma_separated_integer_list]) instead.',
|
||||
obj=CommaSeparatedIntegerModel._meta.get_field('csi'),
|
||||
id='fields.W901',
|
||||
id='fields.E901',
|
||||
)],
|
||||
)
|
||||
|
|
|
@ -163,28 +163,27 @@ class VerboseNameField(models.Model):
|
|||
field1 = models.BigIntegerField("verbose field1")
|
||||
field2 = models.BooleanField("verbose field2", default=False)
|
||||
field3 = models.CharField("verbose field3", max_length=10)
|
||||
field4 = models.CommaSeparatedIntegerField("verbose field4", max_length=99)
|
||||
field5 = models.DateField("verbose field5")
|
||||
field6 = models.DateTimeField("verbose field6")
|
||||
field7 = models.DecimalField("verbose field7", max_digits=6, decimal_places=1)
|
||||
field8 = models.EmailField("verbose field8")
|
||||
field9 = models.FileField("verbose field9", upload_to="unused")
|
||||
field10 = models.FilePathField("verbose field10")
|
||||
field11 = models.FloatField("verbose field11")
|
||||
field4 = models.DateField("verbose field4")
|
||||
field5 = models.DateTimeField("verbose field5")
|
||||
field6 = models.DecimalField("verbose field6", max_digits=6, decimal_places=1)
|
||||
field7 = models.EmailField("verbose field7")
|
||||
field8 = models.FileField("verbose field8", upload_to="unused")
|
||||
field9 = models.FilePathField("verbose field9")
|
||||
field10 = models.FloatField("verbose field10")
|
||||
# Don't want to depend on Pillow in this test
|
||||
# field_image = models.ImageField("verbose field")
|
||||
field12 = models.IntegerField("verbose field12")
|
||||
field13 = models.GenericIPAddressField("verbose field13", protocol="ipv4")
|
||||
field14 = models.NullBooleanField("verbose field14")
|
||||
field15 = models.PositiveIntegerField("verbose field15")
|
||||
field16 = models.PositiveSmallIntegerField("verbose field16")
|
||||
field17 = models.SlugField("verbose field17")
|
||||
field18 = models.SmallIntegerField("verbose field18")
|
||||
field19 = models.TextField("verbose field19")
|
||||
field20 = models.TimeField("verbose field20")
|
||||
field21 = models.URLField("verbose field21")
|
||||
field22 = models.UUIDField("verbose field22")
|
||||
field23 = models.DurationField("verbose field23")
|
||||
field11 = models.IntegerField("verbose field11")
|
||||
field12 = models.GenericIPAddressField("verbose field12", protocol="ipv4")
|
||||
field13 = models.NullBooleanField("verbose field13")
|
||||
field14 = models.PositiveIntegerField("verbose field14")
|
||||
field15 = models.PositiveSmallIntegerField("verbose field15")
|
||||
field16 = models.SlugField("verbose field16")
|
||||
field17 = models.SmallIntegerField("verbose field17")
|
||||
field18 = models.TextField("verbose field18")
|
||||
field19 = models.TimeField("verbose field19")
|
||||
field20 = models.URLField("verbose field20")
|
||||
field21 = models.UUIDField("verbose field21")
|
||||
field22 = models.DurationField("verbose field22")
|
||||
|
||||
|
||||
class GenericIPAddress(models.Model):
|
||||
|
@ -322,7 +321,6 @@ class AllFieldsModel(models.Model):
|
|||
binary = models.BinaryField()
|
||||
boolean = models.BooleanField(default=False)
|
||||
char = models.CharField(max_length=10)
|
||||
csv = models.CommaSeparatedIntegerField(max_length=10)
|
||||
date = models.DateField()
|
||||
datetime = models.DateTimeField()
|
||||
decimal = models.DecimalField(decimal_places=2, max_digits=2)
|
||||
|
|
|
@ -6,11 +6,10 @@ from decimal import Decimal
|
|||
|
||||
from django.db.models.fields import (
|
||||
AutoField, BigIntegerField, BinaryField, BooleanField, CharField,
|
||||
CommaSeparatedIntegerField, DateField, DateTimeField, DecimalField,
|
||||
EmailField, FilePathField, FloatField, GenericIPAddressField, IntegerField,
|
||||
IPAddressField, NullBooleanField, PositiveIntegerField,
|
||||
PositiveSmallIntegerField, SlugField, SmallIntegerField, TextField,
|
||||
TimeField, URLField,
|
||||
DateField, DateTimeField, DecimalField, EmailField, FilePathField,
|
||||
FloatField, GenericIPAddressField, IntegerField, IPAddressField,
|
||||
NullBooleanField, PositiveIntegerField, PositiveSmallIntegerField,
|
||||
SlugField, SmallIntegerField, TextField, TimeField, URLField,
|
||||
)
|
||||
from django.db.models.fields.files import FileField, ImageField
|
||||
from django.test import SimpleTestCase
|
||||
|
@ -43,12 +42,6 @@ class PromiseTest(SimpleTestCase):
|
|||
lazy_func = lazy(lambda: 0, int)
|
||||
self.assertIsInstance(CharField().get_prep_value(lazy_func()), six.text_type)
|
||||
|
||||
def test_CommaSeparatedIntegerField(self):
|
||||
lazy_func = lazy(lambda: '1,2', six.text_type)
|
||||
self.assertIsInstance(CommaSeparatedIntegerField().get_prep_value(lazy_func()), six.text_type)
|
||||
lazy_func = lazy(lambda: 0, int)
|
||||
self.assertIsInstance(CommaSeparatedIntegerField().get_prep_value(lazy_func()), six.text_type)
|
||||
|
||||
def test_DateField(self):
|
||||
lazy_func = lazy(lambda: datetime.date.today(), datetime.date)
|
||||
self.assertIsInstance(DateField().get_prep_value(lazy_func()), datetime.date)
|
||||
|
|
|
@ -42,7 +42,7 @@ class BasicFieldTests(TestCase):
|
|||
|
||||
def test_field_verbose_name(self):
|
||||
m = VerboseNameField
|
||||
for i in range(1, 24):
|
||||
for i in range(1, 23):
|
||||
self.assertEqual(m._meta.get_field('field%d' % i).verbose_name, 'verbose field%d' % i)
|
||||
|
||||
self.assertEqual(m._meta.get_field('id').verbose_name, 'verbose pk')
|
||||
|
|
|
@ -218,14 +218,6 @@ except ImportError:
|
|||
test_images = False
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CommaSeparatedInteger(models.Model):
|
||||
field = models.CommaSeparatedIntegerField(max_length=20)
|
||||
|
||||
def __str__(self):
|
||||
return self.field
|
||||
|
||||
|
||||
class Homepage(models.Model):
|
||||
url = models.URLField()
|
||||
|
||||
|
|
|
@ -24,12 +24,12 @@ from django.utils._os import upath
|
|||
|
||||
from .models import (
|
||||
Article, ArticleStatus, Author, Author1, Award, BetterWriter, BigInt, Book,
|
||||
Category, Character, Colour, ColourfulItem, CommaSeparatedInteger,
|
||||
CustomErrorMessage, CustomFF, CustomFieldForExclusionModel, DateTimePost,
|
||||
DerivedBook, DerivedPost, Document, ExplicitPK, FilePathModel,
|
||||
FlexibleDatePost, Homepage, ImprovedArticle, ImprovedArticleWithParentLink,
|
||||
Inventory, NullableUniqueCharFieldModel, Person, Photo, Post, Price,
|
||||
Product, Publication, PublicationDefaults, StrictAssignmentAll,
|
||||
Category, Character, Colour, ColourfulItem, CustomErrorMessage, CustomFF,
|
||||
CustomFieldForExclusionModel, DateTimePost, DerivedBook, DerivedPost,
|
||||
Document, ExplicitPK, FilePathModel, FlexibleDatePost, Homepage,
|
||||
ImprovedArticle, ImprovedArticleWithParentLink, Inventory,
|
||||
NullableUniqueCharFieldModel, Person, Photo, Post, Price, Product,
|
||||
Publication, PublicationDefaults, StrictAssignmentAll,
|
||||
StrictAssignmentFieldSpecific, Student, StumpJoke, TextFile, Triple,
|
||||
Writer, WriterProfile, test_images,
|
||||
)
|
||||
|
@ -2411,35 +2411,6 @@ class ModelOtherFieldTests(SimpleTestCase):
|
|||
self.assertFalse(bif.is_valid())
|
||||
self.assertEqual(bif.errors, {'biggie': ['Ensure this value is less than or equal to 9223372036854775807.']})
|
||||
|
||||
def test_comma_separated_integer_field(self):
|
||||
class CommaSeparatedIntegerForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = CommaSeparatedInteger
|
||||
fields = '__all__'
|
||||
|
||||
f = CommaSeparatedIntegerForm({'field': '1'})
|
||||
self.assertTrue(f.is_valid())
|
||||
self.assertEqual(f.cleaned_data, {'field': '1'})
|
||||
f = CommaSeparatedIntegerForm({'field': '12'})
|
||||
self.assertTrue(f.is_valid())
|
||||
self.assertEqual(f.cleaned_data, {'field': '12'})
|
||||
f = CommaSeparatedIntegerForm({'field': '1,2,3'})
|
||||
self.assertTrue(f.is_valid())
|
||||
self.assertEqual(f.cleaned_data, {'field': '1,2,3'})
|
||||
f = CommaSeparatedIntegerForm({'field': '10,32'})
|
||||
self.assertTrue(f.is_valid())
|
||||
self.assertEqual(f.cleaned_data, {'field': '10,32'})
|
||||
f = CommaSeparatedIntegerForm({'field': '1a,2'})
|
||||
self.assertEqual(f.errors, {'field': ['Enter only digits separated by commas.']})
|
||||
f = CommaSeparatedIntegerForm({'field': ',,,,'})
|
||||
self.assertEqual(f.errors, {'field': ['Enter only digits separated by commas.']})
|
||||
f = CommaSeparatedIntegerForm({'field': '1.2'})
|
||||
self.assertEqual(f.errors, {'field': ['Enter only digits separated by commas.']})
|
||||
f = CommaSeparatedIntegerForm({'field': '1,a,2'})
|
||||
self.assertEqual(f.errors, {'field': ['Enter only digits separated by commas.']})
|
||||
f = CommaSeparatedIntegerForm({'field': '1,,2'})
|
||||
self.assertEqual(f.errors, {'field': ['Enter only digits separated by commas.']})
|
||||
|
||||
def test_url_on_modelform(self):
|
||||
"Check basic URL field validation on model forms"
|
||||
class HomepageForm(forms.ModelForm):
|
||||
|
|
|
@ -217,7 +217,6 @@ class Station(SearchableLocation):
|
|||
|
||||
|
||||
class BusStation(Station):
|
||||
bus_routes = models.CommaSeparatedIntegerField(max_length=128)
|
||||
inbound = models.BooleanField(default=False)
|
||||
|
||||
|
||||
|
|
|
@ -165,7 +165,6 @@ def setup(verbosity, test_labels, parallel):
|
|||
settings.LOGGING = log_config
|
||||
settings.SILENCED_SYSTEM_CHECKS = [
|
||||
'fields.W342', # ForeignKey(unique=True) -> OneToOneField
|
||||
'fields.W901', # CommaSeparatedIntegerField deprecated
|
||||
]
|
||||
|
||||
# Load all the ALWAYS_INSTALLED_APPS.
|
||||
|
|
Loading…
Reference in New Issue