Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
33457cd3
Kaydet (Commit)
33457cd3
authored
Ock 18, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Removed IPAddressField per deprecation timeline; refs #20439.
üst
5008a4db
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
117 additions
and
161 deletions
+117
-161
__init__.py
django/db/models/fields/__init__.py
+4
-9
fields.py
django/forms/fields.py
+2
-16
checks.txt
docs/ref/checks.txt
+4
-1
fields.txt
docs/ref/forms/fields.txt
+0
-16
fields.txt
docs/ref/models/fields.txt
+0
-12
1.4.11.txt
docs/releases/1.4.11.txt
+1
-1
1.5.6.txt
docs/releases/1.5.6.txt
+1
-1
1.6.3.txt
docs/releases/1.6.3.txt
+1
-1
1.6.txt
docs/releases/1.6.txt
+2
-4
1.7.txt
docs/releases/1.7.txt
+2
-2
models.py
tests/expressions_case/models.py
+0
-1
tests.py
tests/expressions_case/tests.py
+0
-15
test_error_messages.py
tests/forms_tests/tests/test_error_messages.py
+2
-13
test_extra.py
tests/forms_tests/tests/test_extra.py
+4
-25
models.py
tests/inspectdb/models.py
+0
-1
tests.py
tests/inspectdb/tests.py
+0
-2
test_deprecated_fields.py
tests/invalid_models_tests/test_deprecated_fields.py
+22
-0
0001_initial.py
tests/migrations/deprecated_field_migrations/0001_initial.py
+20
-0
0002_remove_ipaddressfield_ip.py
...recated_field_migrations/0002_remove_ipaddressfield_ip.py
+18
-0
__init__.py
tests/migrations/deprecated_field_migrations/__init__.py
+0
-0
test_deprecated_fields.py
tests/migrations/test_deprecated_fields.py
+22
-0
models.py
tests/model_fields/models.py
+9
-11
tests.py
tests/model_fields/tests.py
+1
-17
models.py
tests/serializers_regress/models.py
+0
-8
tests.py
tests/serializers_regress/tests.py
+2
-5
No files found.
django/db/models/fields/__init__.py
Dosyayı görüntüle @
33457cd3
...
@@ -1894,13 +1894,13 @@ class BigIntegerField(IntegerField):
...
@@ -1894,13 +1894,13 @@ class BigIntegerField(IntegerField):
class
IPAddressField
(
Field
):
class
IPAddressField
(
Field
):
empty_strings_allowed
=
False
empty_strings_allowed
=
False
description
=
_
(
"IPv4 address"
)
description
=
_
(
"IPv4 address"
)
system_check_
deprecat
ed_details
=
{
system_check_
remov
ed_details
=
{
'msg'
:
(
'msg'
:
(
'IPAddressField has been
deprecated. Support for it (excep
t in '
'IPAddressField has been
removed except for suppor
t in '
'historical migrations
) will be removed in Django 1.9
.'
'historical migrations.'
),
),
'hint'
:
'Use GenericIPAddressField instead.'
,
'hint'
:
'Use GenericIPAddressField instead.'
,
'id'
:
'fields.
W
900'
,
'id'
:
'fields.
E
900'
,
}
}
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
@@ -1921,11 +1921,6 @@ class IPAddressField(Field):
...
@@ -1921,11 +1921,6 @@ class IPAddressField(Field):
def
get_internal_type
(
self
):
def
get_internal_type
(
self
):
return
"IPAddressField"
return
"IPAddressField"
def
formfield
(
self
,
**
kwargs
):
defaults
=
{
'form_class'
:
forms
.
IPAddressField
}
defaults
.
update
(
kwargs
)
return
super
(
IPAddressField
,
self
)
.
formfield
(
**
defaults
)
class
GenericIPAddressField
(
Field
):
class
GenericIPAddressField
(
Field
):
empty_strings_allowed
=
False
empty_strings_allowed
=
False
...
...
django/forms/fields.py
Dosyayı görüntüle @
33457cd3
...
@@ -27,7 +27,7 @@ from django.utils import formats
...
@@ -27,7 +27,7 @@ from django.utils import formats
from
django.utils.encoding
import
smart_text
,
force_str
,
force_text
from
django.utils.encoding
import
smart_text
,
force_str
,
force_text
from
django.utils.ipv6
import
clean_ipv6_address
from
django.utils.ipv6
import
clean_ipv6_address
from
django.utils.dateparse
import
parse_duration
from
django.utils.dateparse
import
parse_duration
from
django.utils.deprecation
import
RemovedInDjango
19Warning
,
RemovedInDjango
20Warning
,
RenameMethodsBase
from
django.utils.deprecation
import
RemovedInDjango20Warning
,
RenameMethodsBase
from
django.utils.duration
import
duration_string
from
django.utils.duration
import
duration_string
from
django.utils
import
six
from
django.utils
import
six
from
django.utils.six.moves.urllib.parse
import
urlsplit
,
urlunsplit
from
django.utils.six.moves.urllib.parse
import
urlsplit
,
urlunsplit
...
@@ -43,7 +43,7 @@ __all__ = (
...
@@ -43,7 +43,7 @@ __all__ = (
'RegexField'
,
'EmailField'
,
'FileField'
,
'ImageField'
,
'URLField'
,
'RegexField'
,
'EmailField'
,
'FileField'
,
'ImageField'
,
'URLField'
,
'BooleanField'
,
'NullBooleanField'
,
'ChoiceField'
,
'MultipleChoiceField'
,
'BooleanField'
,
'NullBooleanField'
,
'ChoiceField'
,
'MultipleChoiceField'
,
'ComboField'
,
'MultiValueField'
,
'FloatField'
,
'DecimalField'
,
'ComboField'
,
'MultiValueField'
,
'FloatField'
,
'DecimalField'
,
'SplitDateTimeField'
,
'
IPAddressField'
,
'
GenericIPAddressField'
,
'FilePathField'
,
'SplitDateTimeField'
,
'GenericIPAddressField'
,
'FilePathField'
,
'SlugField'
,
'TypedChoiceField'
,
'TypedMultipleChoiceField'
,
'UUIDField'
,
'SlugField'
,
'TypedChoiceField'
,
'TypedMultipleChoiceField'
,
'UUIDField'
,
)
)
...
@@ -1206,20 +1206,6 @@ class SplitDateTimeField(MultiValueField):
...
@@ -1206,20 +1206,6 @@ class SplitDateTimeField(MultiValueField):
return
None
return
None
class
IPAddressField
(
CharField
):
default_validators
=
[
validators
.
validate_ipv4_address
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
warnings
.
warn
(
"IPAddressField has been deprecated. Use GenericIPAddressField instead."
,
RemovedInDjango19Warning
)
super
(
IPAddressField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
to_python
(
self
,
value
):
if
value
in
self
.
empty_values
:
return
''
return
value
.
strip
()
class
GenericIPAddressField
(
CharField
):
class
GenericIPAddressField
(
CharField
):
def
__init__
(
self
,
protocol
=
'both'
,
unpack_ipv4
=
False
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
protocol
=
'both'
,
unpack_ipv4
=
False
,
*
args
,
**
kwargs
):
self
.
unpack_ipv4
=
unpack_ipv4
self
.
unpack_ipv4
=
unpack_ipv4
...
...
docs/ref/checks.txt
Dosyayı görüntüle @
33457cd3
...
@@ -95,8 +95,11 @@ Fields
...
@@ -95,8 +95,11 @@ Fields
* **fields.E160**: The options ``auto_now``, ``auto_now_add``, and ``default``
* **fields.E160**: The options ``auto_now``, ``auto_now_add``, and ``default``
are mutually exclusive. Only one of these options may be present.
are mutually exclusive. Only one of these options may be present.
* **fields.W161**: Fixed default value provided.
* **fields.W161**: Fixed default value provided.
* **fields.E900**: ``IPAddressField`` has been removed except for support in
historical migrations.
* **fields.W900**: ``IPAddressField`` has been deprecated. Support for it
* **fields.W900**: ``IPAddressField`` has been deprecated. Support for it
(except in historical migrations) will be removed in Django 1.9.
(except in historical migrations) will be removed in Django 1.9. *This check
appeared in Django 1.7 and 1.8*.
File Fields
File Fields
~~~~~~~~~~~
~~~~~~~~~~~
...
...
docs/ref/forms/fields.txt
Dosyayı görüntüle @
33457cd3
...
@@ -719,22 +719,6 @@ For each field, we describe the default widget used if you don't specify
...
@@ -719,22 +719,6 @@ For each field, we describe the default widget used if you don't specify
These control the range of values permitted in the field.
These control the range of values permitted in the field.
``IPAddressField``
~~~~~~~~~~~~~~~~~~
.. class:: IPAddressField(**kwargs)
.. deprecated:: 1.7
This field has been deprecated in favor of
:class:`~django.forms.GenericIPAddressField`.
* Default widget: :class:`TextInput`
* Empty value: ``''`` (an empty string)
* Normalizes to: A Unicode object.
* Validates that the given value is a valid IPv4 address, using a regular
expression.
* Error message keys: ``required``, ``invalid``
``GenericIPAddressField``
``GenericIPAddressField``
~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
docs/ref/models/fields.txt
Dosyayı görüntüle @
33457cd3
...
@@ -892,18 +892,6 @@ An integer. Values from ``-2147483648`` to ``2147483647`` are safe in all
...
@@ -892,18 +892,6 @@ An integer. Values from ``-2147483648`` to ``2147483647`` are safe in all
databases supported by Django. The default form widget for this field is a
databases supported by Django. The default form widget for this field is a
:class:`~django.forms.TextInput`.
:class:`~django.forms.TextInput`.
``IPAddressField``
------------------
.. class:: IPAddressField([**options])
.. deprecated:: 1.7
This field has been deprecated in favor of
:class:`~django.db.models.GenericIPAddressField`.
An IP address, in string format (e.g. "192.0.2.30"). The default form widget
for this field is a :class:`~django.forms.TextInput`.
``GenericIPAddressField``
``GenericIPAddressField``
-------------------------
-------------------------
...
...
docs/releases/1.4.11.txt
Dosyayı görüntüle @
33457cd3
...
@@ -96,7 +96,7 @@ field classes did not correctly convert their arguments:
...
@@ -96,7 +96,7 @@ field classes did not correctly convert their arguments:
* :class:`~django.db.models.FilePathField`
* :class:`~django.db.models.FilePathField`
* :class:`~django.db.models.GenericIPAddressField`
* :class:`~django.db.models.GenericIPAddressField`
*
:class:`~django.db.models.IPAddressField
`
*
``IPAddressField`
`
These three fields have been updated to convert their arguments to the
These three fields have been updated to convert their arguments to the
correct types before querying.
correct types before querying.
...
...
docs/releases/1.5.6.txt
Dosyayı görüntüle @
33457cd3
...
@@ -95,7 +95,7 @@ field classes did not correctly convert their arguments:
...
@@ -95,7 +95,7 @@ field classes did not correctly convert their arguments:
* :class:`~django.db.models.FilePathField`
* :class:`~django.db.models.FilePathField`
* :class:`~django.db.models.GenericIPAddressField`
* :class:`~django.db.models.GenericIPAddressField`
*
:class:`~django.db.models.IPAddressField
`
*
``IPAddressField`
`
These three fields have been updated to convert their arguments to the
These three fields have been updated to convert their arguments to the
correct types before querying.
correct types before querying.
...
...
docs/releases/1.6.3.txt
Dosyayı görüntüle @
33457cd3
...
@@ -95,7 +95,7 @@ field classes did not correctly convert their arguments:
...
@@ -95,7 +95,7 @@ field classes did not correctly convert their arguments:
* :class:`~django.db.models.FilePathField`
* :class:`~django.db.models.FilePathField`
* :class:`~django.db.models.GenericIPAddressField`
* :class:`~django.db.models.GenericIPAddressField`
*
:class:`~django.db.models.IPAddressField
`
*
``IPAddressField`
`
These three fields have been updated to convert their arguments to the
These three fields have been updated to convert their arguments to the
correct types before querying.
correct types before querying.
...
...
docs/releases/1.6.txt
Dosyayı görüntüle @
33457cd3
...
@@ -876,10 +876,8 @@ Miscellaneous
...
@@ -876,10 +876,8 @@ Miscellaneous
:class:`~django.forms.ModelMultipleChoiceField`.
:class:`~django.forms.ModelMultipleChoiceField`.
* Some :attr:`~django.forms.Field.error_messages` for
* Some :attr:`~django.forms.Field.error_messages` for
:class:`~django.forms.IntegerField`,
:class:`~django.forms.IntegerField`, :class:`~django.forms.EmailField`,
:class:`~django.forms.EmailField`,
``IPAddressField``, :class:`~django.forms.GenericIPAddressField`, and
:class:`~django.forms.IPAddressField`,
:class:`~django.forms.GenericIPAddressField`, and
:class:`~django.forms.SlugField` have been suppressed because they
:class:`~django.forms.SlugField` have been suppressed because they
duplicated error messages already provided by validators tied to the fields.
duplicated error messages already provided by validators tied to the fields.
...
...
docs/releases/1.7.txt
Dosyayı görüntüle @
33457cd3
...
@@ -1591,8 +1591,8 @@ better handle the case of selectively showing inlines on a ``ModelAdmin``.
...
@@ -1591,8 +1591,8 @@ better handle the case of selectively showing inlines on a ``ModelAdmin``.
``IPAddressField``
``IPAddressField``
~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~
The
:class:`django.db.models.IPAddressField` and
The
``django.db.models.IPAddressField`` and ``django.forms.IPAddressField``
:class:`django.forms.IPAddressField`
fields have been deprecated in favor of
fields have been deprecated in favor of
:class:`django.db.models.GenericIPAddressField` and
:class:`django.db.models.GenericIPAddressField` and
:class:`django.forms.GenericIPAddressField`.
:class:`django.forms.GenericIPAddressField`.
...
...
tests/expressions_case/models.py
Dosyayı görüntüle @
33457cd3
...
@@ -29,7 +29,6 @@ class CaseTestModel(models.Model):
...
@@ -29,7 +29,6 @@ class CaseTestModel(models.Model):
float
=
models
.
FloatField
(
null
=
True
,
db_column
=
'float_field'
)
float
=
models
.
FloatField
(
null
=
True
,
db_column
=
'float_field'
)
if
Image
:
if
Image
:
image
=
models
.
ImageField
(
null
=
True
)
image
=
models
.
ImageField
(
null
=
True
)
ip_address
=
models
.
IPAddressField
(
null
=
True
)
generic_ip_address
=
models
.
GenericIPAddressField
(
null
=
True
)
generic_ip_address
=
models
.
GenericIPAddressField
(
null
=
True
)
null_boolean
=
models
.
NullBooleanField
()
null_boolean
=
models
.
NullBooleanField
()
positive_integer
=
models
.
PositiveIntegerField
(
null
=
True
)
positive_integer
=
models
.
PositiveIntegerField
(
null
=
True
)
...
...
tests/expressions_case/tests.py
Dosyayı görüntüle @
33457cd3
...
@@ -752,21 +752,6 @@ class CaseExpressionTests(TestCase):
...
@@ -752,21 +752,6 @@ class CaseExpressionTests(TestCase):
transform
=
lambda
o
:
(
o
.
integer
,
six
.
text_type
(
o
.
image
))
transform
=
lambda
o
:
(
o
.
integer
,
six
.
text_type
(
o
.
image
))
)
)
def
test_update_ip_address
(
self
):
CaseTestModel
.
objects
.
update
(
ip_address
=
Case
(
# fails on postgresql if output_field is not set explicitly
When
(
integer
=
1
,
then
=
Value
(
'1.1.1.1'
)),
When
(
integer
=
2
,
then
=
Value
(
'2.2.2.2'
)),
output_field
=
models
.
IPAddressField
(),
),
)
self
.
assertQuerysetEqual
(
CaseTestModel
.
objects
.
all
()
.
order_by
(
'pk'
),
[(
1
,
'1.1.1.1'
),
(
2
,
'2.2.2.2'
),
(
3
,
None
),
(
2
,
'2.2.2.2'
),
(
3
,
None
),
(
3
,
None
),
(
4
,
None
)],
transform
=
attrgetter
(
'integer'
,
'ip_address'
)
)
def
test_update_generic_ip_address
(
self
):
def
test_update_generic_ip_address
(
self
):
CaseTestModel
.
objects
.
update
(
CaseTestModel
.
objects
.
update
(
generic_ip_address
=
Case
(
generic_ip_address
=
Case
(
...
...
tests/forms_tests/tests/test_error_messages.py
Dosyayı görüntüle @
33457cd3
...
@@ -5,12 +5,11 @@ from django.core.files.uploadedfile import SimpleUploadedFile
...
@@ -5,12 +5,11 @@ from django.core.files.uploadedfile import SimpleUploadedFile
from
django.forms
import
(
from
django.forms
import
(
BooleanField
,
CharField
,
ChoiceField
,
DateField
,
DateTimeField
,
BooleanField
,
CharField
,
ChoiceField
,
DateField
,
DateTimeField
,
DecimalField
,
EmailField
,
FileField
,
FloatField
,
Form
,
DecimalField
,
EmailField
,
FileField
,
FloatField
,
Form
,
GenericIPAddressField
,
IntegerField
,
IPAddressField
,
ModelChoiceField
,
GenericIPAddressField
,
IntegerField
,
ModelChoiceField
,
ModelMultipleChoiceField
,
MultipleChoiceField
,
RegexField
,
ModelMultipleChoiceField
,
MultipleChoiceField
,
RegexField
,
SplitDateTimeField
,
TimeField
,
URLField
,
utils
,
ValidationError
,
SplitDateTimeField
,
TimeField
,
URLField
,
utils
,
ValidationError
,
)
)
from
django.test
import
ignore_warnings
,
TestCase
from
django.test
import
TestCase
from
django.utils.deprecation
import
RemovedInDjango19Warning
from
django.utils.safestring
import
mark_safe
from
django.utils.safestring
import
mark_safe
from
django.utils.encoding
import
python_2_unicode_compatible
from
django.utils.encoding
import
python_2_unicode_compatible
...
@@ -197,16 +196,6 @@ class FormsErrorMessagesTestCase(TestCase, AssertFormErrorsMixin):
...
@@ -197,16 +196,6 @@ class FormsErrorMessagesTestCase(TestCase, AssertFormErrorsMixin):
self
.
assertFormErrors
([
'REQUIRED'
],
f
.
clean
,
''
)
self
.
assertFormErrors
([
'REQUIRED'
],
f
.
clean
,
''
)
self
.
assertFormErrors
([
'INVALID DATE'
,
'INVALID TIME'
],
f
.
clean
,
[
'a'
,
'b'
])
self
.
assertFormErrors
([
'INVALID DATE'
,
'INVALID TIME'
],
f
.
clean
,
[
'a'
,
'b'
])
@ignore_warnings
(
category
=
RemovedInDjango19Warning
)
def
test_ipaddressfield
(
self
):
e
=
{
'required'
:
'REQUIRED'
,
'invalid'
:
'INVALID IP ADDRESS'
,
}
f
=
IPAddressField
(
error_messages
=
e
)
self
.
assertFormErrors
([
'REQUIRED'
],
f
.
clean
,
''
)
self
.
assertFormErrors
([
'INVALID IP ADDRESS'
],
f
.
clean
,
'127.0.0'
)
def
test_generic_ipaddressfield
(
self
):
def
test_generic_ipaddressfield
(
self
):
e
=
{
e
=
{
'required'
:
'REQUIRED'
,
'required'
:
'REQUIRED'
,
...
...
tests/forms_tests/tests/test_extra.py
Dosyayı görüntüle @
33457cd3
...
@@ -5,17 +5,16 @@ import datetime
...
@@ -5,17 +5,16 @@ import datetime
from
django.forms
import
(
from
django.forms
import
(
CharField
,
DateField
,
EmailField
,
FileField
,
Form
,
GenericIPAddressField
,
CharField
,
DateField
,
EmailField
,
FileField
,
Form
,
GenericIPAddressField
,
HiddenInput
,
ImageField
,
IPAddressField
,
MultipleChoiceField
,
HiddenInput
,
ImageField
,
MultipleChoiceField
,
MultiValueField
,
MultiWidget
,
MultiValueField
,
MultiWidget
,
PasswordInput
,
SelectMultiple
,
Slug
Field
,
PasswordInput
,
SelectMultiple
,
SlugField
,
SplitDateTime
Field
,
SplitDateTime
Field
,
SplitDateTime
Widget
,
TextInput
,
URLField
,
SplitDateTimeWidget
,
TextInput
,
URLField
,
)
)
from
django.forms.extras
import
SelectDateWidget
from
django.forms.extras
import
SelectDateWidget
from
django.forms.utils
import
ErrorList
from
django.forms.utils
import
ErrorList
from
django.test
import
TestCase
,
ignore_warnings
,
override_settings
from
django.test
import
TestCase
,
override_settings
from
django.utils
import
six
from
django.utils
import
six
from
django.utils
import
translation
from
django.utils
import
translation
from
django.utils.dates
import
MONTHS_AP
from
django.utils.dates
import
MONTHS_AP
from
django.utils.deprecation
import
RemovedInDjango19Warning
from
django.utils.encoding
import
force_text
,
smart_text
,
python_2_unicode_compatible
from
django.utils.encoding
import
force_text
,
smart_text
,
python_2_unicode_compatible
from
.test_error_messages
import
AssertFormErrorsMixin
from
.test_error_messages
import
AssertFormErrorsMixin
...
@@ -483,26 +482,6 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
...
@@ -483,26 +482,6 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
self
.
assertEqual
(
f
.
cleaned_data
[
'field1'
],
'some text,JP,2007-04-25 06:24:00'
)
self
.
assertEqual
(
f
.
cleaned_data
[
'field1'
],
'some text,JP,2007-04-25 06:24:00'
)
@ignore_warnings
(
category
=
RemovedInDjango19Warning
)
def
test_ipaddress
(
self
):
f
=
IPAddressField
()
self
.
assertFormErrors
([
'This field is required.'
],
f
.
clean
,
''
)
self
.
assertFormErrors
([
'This field is required.'
],
f
.
clean
,
None
)
self
.
assertEqual
(
f
.
clean
(
' 127.0.0.1'
),
'127.0.0.1'
)
self
.
assertFormErrors
([
'Enter a valid IPv4 address.'
],
f
.
clean
,
'foo'
)
self
.
assertFormErrors
([
'Enter a valid IPv4 address.'
],
f
.
clean
,
'127.0.0.'
)
self
.
assertFormErrors
([
'Enter a valid IPv4 address.'
],
f
.
clean
,
'1.2.3.4.5'
)
self
.
assertFormErrors
([
'Enter a valid IPv4 address.'
],
f
.
clean
,
'256.125.1.5'
)
f
=
IPAddressField
(
required
=
False
)
self
.
assertEqual
(
f
.
clean
(
''
),
''
)
self
.
assertEqual
(
f
.
clean
(
None
),
''
)
self
.
assertEqual
(
f
.
clean
(
' 127.0.0.1'
),
'127.0.0.1'
)
self
.
assertFormErrors
([
'Enter a valid IPv4 address.'
],
f
.
clean
,
'foo'
)
self
.
assertFormErrors
([
'Enter a valid IPv4 address.'
],
f
.
clean
,
'127.0.0.'
)
self
.
assertFormErrors
([
'Enter a valid IPv4 address.'
],
f
.
clean
,
'1.2.3.4.5'
)
self
.
assertFormErrors
([
'Enter a valid IPv4 address.'
],
f
.
clean
,
'256.125.1.5'
)
def
test_generic_ipaddress_invalid_arguments
(
self
):
def
test_generic_ipaddress_invalid_arguments
(
self
):
self
.
assertRaises
(
ValueError
,
GenericIPAddressField
,
protocol
=
"hamster"
)
self
.
assertRaises
(
ValueError
,
GenericIPAddressField
,
protocol
=
"hamster"
)
self
.
assertRaises
(
ValueError
,
GenericIPAddressField
,
protocol
=
"ipv4"
,
unpack_ipv4
=
True
)
self
.
assertRaises
(
ValueError
,
GenericIPAddressField
,
protocol
=
"ipv4"
,
unpack_ipv4
=
True
)
...
...
tests/inspectdb/models.py
Dosyayı görüntüle @
33457cd3
...
@@ -59,7 +59,6 @@ class ColumnTypes(models.Model):
...
@@ -59,7 +59,6 @@ class ColumnTypes(models.Model):
file_path_field
=
models
.
FilePathField
()
file_path_field
=
models
.
FilePathField
()
float_field
=
models
.
FloatField
()
float_field
=
models
.
FloatField
()
int_field
=
models
.
IntegerField
()
int_field
=
models
.
IntegerField
()
ip_address_field
=
models
.
IPAddressField
()
gen_ip_adress_field
=
models
.
GenericIPAddressField
(
protocol
=
"ipv4"
)
gen_ip_adress_field
=
models
.
GenericIPAddressField
(
protocol
=
"ipv4"
)
pos_int_field
=
models
.
PositiveIntegerField
()
pos_int_field
=
models
.
PositiveIntegerField
()
pos_small_int_field
=
models
.
PositiveSmallIntegerField
()
pos_small_int_field
=
models
.
PositiveSmallIntegerField
()
...
...
tests/inspectdb/tests.py
Dosyayı görüntüle @
33457cd3
...
@@ -61,11 +61,9 @@ class InspectDBTestCase(TestCase):
...
@@ -61,11 +61,9 @@ class InspectDBTestCase(TestCase):
assertFieldType
(
'file_field'
,
"models.CharField(max_length=100)"
)
assertFieldType
(
'file_field'
,
"models.CharField(max_length=100)"
)
assertFieldType
(
'file_path_field'
,
"models.CharField(max_length=100)"
)
assertFieldType
(
'file_path_field'
,
"models.CharField(max_length=100)"
)
if
connection
.
features
.
can_introspect_ip_address_field
:
if
connection
.
features
.
can_introspect_ip_address_field
:
assertFieldType
(
'ip_address_field'
,
"models.GenericIPAddressField()"
)
assertFieldType
(
'gen_ip_adress_field'
,
"models.GenericIPAddressField()"
)
assertFieldType
(
'gen_ip_adress_field'
,
"models.GenericIPAddressField()"
)
elif
(
connection
.
features
.
can_introspect_max_length
and
elif
(
connection
.
features
.
can_introspect_max_length
and
not
connection
.
features
.
interprets_empty_strings_as_nulls
):
not
connection
.
features
.
interprets_empty_strings_as_nulls
):
assertFieldType
(
'ip_address_field'
,
"models.CharField(max_length=15)"
)
assertFieldType
(
'gen_ip_adress_field'
,
"models.CharField(max_length=39)"
)
assertFieldType
(
'gen_ip_adress_field'
,
"models.CharField(max_length=39)"
)
if
(
connection
.
features
.
can_introspect_max_length
and
if
(
connection
.
features
.
can_introspect_max_length
and
not
connection
.
features
.
interprets_empty_strings_as_nulls
):
not
connection
.
features
.
interprets_empty_strings_as_nulls
):
...
...
tests/invalid_models_tests/test_deprecated_fields.py
0 → 100644
Dosyayı görüntüle @
33457cd3
from
django.core
import
checks
from
django.db
import
models
from
.base
import
IsolatedModelsTestCase
class
DeprecatedFieldssTests
(
IsolatedModelsTestCase
):
def
test_IPAddressField_deprecated
(
self
):
class
IPAddressModel
(
models
.
Model
):
ip
=
models
.
IPAddressField
()
model
=
IPAddressModel
()
self
.
assertEqual
(
model
.
check
(),
[
checks
.
Error
(
'IPAddressField has been removed except for support in '
'historical migrations.'
,
hint
=
'Use GenericIPAddressField instead.'
,
obj
=
IPAddressModel
.
_meta
.
get_field
(
'ip'
),
id
=
'fields.E900'
,
)],
)
tests/migrations/deprecated_field_migrations/0001_initial.py
0 → 100644
Dosyayı görüntüle @
33457cd3
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
models
,
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
]
operations
=
[
migrations
.
CreateModel
(
name
=
'IPAddressField'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
verbose_name
=
'ID'
,
serialize
=
False
,
auto_created
=
True
,
primary_key
=
True
)),
(
'ip'
,
models
.
IPAddressField
(
null
=
True
,
blank
=
True
)),
],
),
]
tests/migrations/deprecated_field_migrations/0002_remove_ipaddressfield_ip.py
0 → 100644
Dosyayı görüntüle @
33457cd3
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'migrations'
,
'0001_initial'
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
'ipaddressfield'
,
name
=
'ip'
,
),
]
tests/migrations/deprecated_field_migrations/__init__.py
0 → 100644
Dosyayı görüntüle @
33457cd3
tests/migrations/test_deprecated_fields.py
0 → 100644
Dosyayı görüntüle @
33457cd3
from
django.core.management
import
call_command
from
django.test
import
override_settings
from
.test_base
import
MigrationTestBase
class
Tests
(
MigrationTestBase
):
"""
Deprecated model fields should still be usable in historic migrations.
"""
@override_settings
(
MIGRATION_MODULES
=
{
"migrations"
:
"migrations.deprecated_field_migrations"
})
def
test_migrate
(
self
):
# Make sure no tables are created
self
.
assertTableNotExists
(
"migrations_ipaddressfield"
)
# Run migration
call_command
(
"migrate"
,
verbosity
=
0
)
# Make sure the right tables exist
self
.
assertTableExists
(
"migrations_ipaddressfield"
)
# Unmigrate everything
call_command
(
"migrate"
,
"migrations"
,
"zero"
,
verbosity
=
0
)
# Make sure it's all gone
self
.
assertTableNotExists
(
"migrations_ipaddressfield"
)
tests/model_fields/models.py
Dosyayı görüntüle @
33457cd3
...
@@ -168,16 +168,15 @@ class VerboseNameField(models.Model):
...
@@ -168,16 +168,15 @@ class VerboseNameField(models.Model):
# Don't want to depend on Pillow in this test
# Don't want to depend on Pillow in this test
#field_image = models.ImageField("verbose field")
#field_image = models.ImageField("verbose field")
field12
=
models
.
IntegerField
(
"verbose field12"
)
field12
=
models
.
IntegerField
(
"verbose field12"
)
field13
=
models
.
IPAddressField
(
"verbose field13"
)
field13
=
models
.
GenericIPAddressField
(
"verbose field13"
,
protocol
=
"ipv4"
)
field14
=
models
.
GenericIPAddressField
(
"verbose field14"
,
protocol
=
"ipv4"
)
field14
=
models
.
NullBooleanField
(
"verbose field14"
)
field15
=
models
.
NullBooleanField
(
"verbose field15"
)
field15
=
models
.
PositiveIntegerField
(
"verbose field15"
)
field16
=
models
.
PositiveIntegerField
(
"verbose field16"
)
field16
=
models
.
PositiveSmallIntegerField
(
"verbose field16"
)
field17
=
models
.
PositiveSmallIntegerField
(
"verbose field17"
)
field17
=
models
.
SlugField
(
"verbose field17"
)
field18
=
models
.
SlugField
(
"verbose field18"
)
field18
=
models
.
SmallIntegerField
(
"verbose field18"
)
field19
=
models
.
SmallIntegerField
(
"verbose field19"
)
field19
=
models
.
TextField
(
"verbose field19"
)
field20
=
models
.
TextField
(
"verbose field20"
)
field20
=
models
.
TimeField
(
"verbose field20"
)
field21
=
models
.
TimeField
(
"verbose field21"
)
field21
=
models
.
URLField
(
"verbose field21"
)
field22
=
models
.
URLField
(
"verbose field22"
)
class
GenericIPAddress
(
models
.
Model
):
class
GenericIPAddress
(
models
.
Model
):
...
@@ -323,7 +322,6 @@ class AllFieldsModel(models.Model):
...
@@ -323,7 +322,6 @@ class AllFieldsModel(models.Model):
file_path
=
models
.
FilePathField
()
file_path
=
models
.
FilePathField
()
floatf
=
models
.
FloatField
()
floatf
=
models
.
FloatField
()
integer
=
models
.
IntegerField
()
integer
=
models
.
IntegerField
()
ip_address
=
models
.
IPAddressField
()
generic_ip
=
models
.
GenericIPAddressField
()
generic_ip
=
models
.
GenericIPAddressField
()
null_boolean
=
models
.
NullBooleanField
()
null_boolean
=
models
.
NullBooleanField
()
positive_integer
=
models
.
PositiveIntegerField
()
positive_integer
=
models
.
PositiveIntegerField
()
...
...
tests/model_fields/tests.py
Dosyayı görüntüle @
33457cd3
...
@@ -75,7 +75,7 @@ class BasicFieldTests(test.TestCase):
...
@@ -75,7 +75,7 @@ class BasicFieldTests(test.TestCase):
def
test_field_verbose_name
(
self
):
def
test_field_verbose_name
(
self
):
m
=
VerboseNameField
m
=
VerboseNameField
for
i
in
range
(
1
,
2
3
):
for
i
in
range
(
1
,
2
2
):
self
.
assertEqual
(
m
.
_meta
.
get_field
(
'field
%
d'
%
i
)
.
verbose_name
,
self
.
assertEqual
(
m
.
_meta
.
get_field
(
'field
%
d'
%
i
)
.
verbose_name
,
'verbose field
%
d'
%
i
)
'verbose field
%
d'
%
i
)
...
@@ -819,22 +819,6 @@ class PromiseTest(test.TestCase):
...
@@ -819,22 +819,6 @@ class PromiseTest(test.TestCase):
IPAddressField
()
.
get_prep_value
(
lazy_func
()),
IPAddressField
()
.
get_prep_value
(
lazy_func
()),
six
.
text_type
)
six
.
text_type
)
def
test_IPAddressField_deprecated
(
self
):
class
IPAddressModel
(
models
.
Model
):
ip
=
IPAddressField
()
model
=
IPAddressModel
()
self
.
assertEqual
(
model
.
check
(),
[
checks
.
Warning
(
'IPAddressField has been deprecated. Support for it '
'(except in historical migrations) will be removed in Django 1.9.'
,
hint
=
'Use GenericIPAddressField instead.'
,
obj
=
IPAddressModel
.
_meta
.
get_field
(
'ip'
),
id
=
'fields.W900'
,
)],
)
def
test_GenericIPAddressField
(
self
):
def
test_GenericIPAddressField
(
self
):
lazy_func
=
lazy
(
lambda
:
'127.0.0.1'
,
six
.
text_type
)
lazy_func
=
lazy
(
lambda
:
'127.0.0.1'
,
six
.
text_type
)
self
.
assertIsInstance
(
self
.
assertIsInstance
(
...
...
tests/serializers_regress/models.py
Dosyayı görüntüle @
33457cd3
...
@@ -65,10 +65,6 @@ class BigIntegerData(models.Model):
...
@@ -65,10 +65,6 @@ class BigIntegerData(models.Model):
# data = models.ImageField(null=True)
# data = models.ImageField(null=True)
class
IPAddressData
(
models
.
Model
):
data
=
models
.
IPAddressField
(
null
=
True
)
class
GenericIPAddressData
(
models
.
Model
):
class
GenericIPAddressData
(
models
.
Model
):
data
=
models
.
GenericIPAddressField
(
null
=
True
)
data
=
models
.
GenericIPAddressField
(
null
=
True
)
...
@@ -245,10 +241,6 @@ class IntegerPKData(models.Model):
...
@@ -245,10 +241,6 @@ class IntegerPKData(models.Model):
# data = models.ImageField(primary_key=True)
# data = models.ImageField(primary_key=True)
class
IPAddressPKData
(
models
.
Model
):
data
=
models
.
IPAddressField
(
primary_key
=
True
)
class
GenericIPAddressPKData
(
models
.
Model
):
class
GenericIPAddressPKData
(
models
.
Model
):
data
=
models
.
GenericIPAddressField
(
primary_key
=
True
)
data
=
models
.
GenericIPAddressField
(
primary_key
=
True
)
...
...
tests/serializers_regress/tests.py
Dosyayı görüntüle @
33457cd3
...
@@ -28,13 +28,13 @@ from django.utils import six
...
@@ -28,13 +28,13 @@ from django.utils import six
from
django.utils.functional
import
curry
from
django.utils.functional
import
curry
from
.models
import
(
BinaryData
,
BooleanData
,
CharData
,
DateData
,
DateTimeData
,
EmailData
,
from
.models
import
(
BinaryData
,
BooleanData
,
CharData
,
DateData
,
DateTimeData
,
EmailData
,
FileData
,
FilePathData
,
DecimalData
,
FloatData
,
IntegerData
,
IPAddressData
,
FileData
,
FilePathData
,
DecimalData
,
FloatData
,
IntegerData
,
GenericIPAddressData
,
NullBooleanData
,
PositiveIntegerData
,
GenericIPAddressData
,
NullBooleanData
,
PositiveIntegerData
,
PositiveSmallIntegerData
,
SlugData
,
SmallData
,
TextData
,
TimeData
,
PositiveSmallIntegerData
,
SlugData
,
SmallData
,
TextData
,
TimeData
,
GenericData
,
Anchor
,
UniqueAnchor
,
FKData
,
M2MData
,
O2OData
,
GenericData
,
Anchor
,
UniqueAnchor
,
FKData
,
M2MData
,
O2OData
,
FKSelfData
,
M2MSelfData
,
FKDataToField
,
FKDataToO2O
,
M2MIntermediateData
,
FKSelfData
,
M2MSelfData
,
FKDataToField
,
FKDataToO2O
,
M2MIntermediateData
,
Intermediate
,
BooleanPKData
,
CharPKData
,
EmailPKData
,
FilePathPKData
,
Intermediate
,
BooleanPKData
,
CharPKData
,
EmailPKData
,
FilePathPKData
,
DecimalPKData
,
FloatPKData
,
IntegerPKData
,
IPAddressPKData
,
DecimalPKData
,
FloatPKData
,
IntegerPKData
,
GenericIPAddressPKData
,
PositiveIntegerPKData
,
GenericIPAddressPKData
,
PositiveIntegerPKData
,
PositiveSmallIntegerPKData
,
SlugPKData
,
SmallPKData
,
PositiveSmallIntegerPKData
,
SlugPKData
,
SmallPKData
,
AutoNowDateTimeData
,
ModifyingSaveData
,
InheritAbstractModel
,
BaseModel
,
AutoNowDateTimeData
,
ModifyingSaveData
,
InheritAbstractModel
,
BaseModel
,
...
@@ -241,8 +241,6 @@ test_data = [
...
@@ -241,8 +241,6 @@ test_data = [
(
data_obj
,
82
,
IntegerData
,
0
),
(
data_obj
,
82
,
IntegerData
,
0
),
(
data_obj
,
83
,
IntegerData
,
None
),
(
data_obj
,
83
,
IntegerData
,
None
),
#(XX, ImageData
#(XX, ImageData
(
data_obj
,
90
,
IPAddressData
,
"127.0.0.1"
),
(
data_obj
,
91
,
IPAddressData
,
None
),
(
data_obj
,
95
,
GenericIPAddressData
,
"fe80:1424:2223:6cff:fe8a:2e8a:2151:abcd"
),
(
data_obj
,
95
,
GenericIPAddressData
,
"fe80:1424:2223:6cff:fe8a:2e8a:2151:abcd"
),
(
data_obj
,
96
,
GenericIPAddressData
,
None
),
(
data_obj
,
96
,
GenericIPAddressData
,
None
),
(
data_obj
,
100
,
NullBooleanData
,
True
),
(
data_obj
,
100
,
NullBooleanData
,
True
),
...
@@ -341,7 +339,6 @@ The end."""),
...
@@ -341,7 +339,6 @@ The end."""),
(
pk_obj
,
681
,
IntegerPKData
,
-
123456789
),
(
pk_obj
,
681
,
IntegerPKData
,
-
123456789
),
(
pk_obj
,
682
,
IntegerPKData
,
0
),
(
pk_obj
,
682
,
IntegerPKData
,
0
),
# (XX, ImagePKData
# (XX, ImagePKData
(
pk_obj
,
690
,
IPAddressPKData
,
"127.0.0.1"
),
(
pk_obj
,
695
,
GenericIPAddressPKData
,
"fe80:1424:2223:6cff:fe8a:2e8a:2151:abcd"
),
(
pk_obj
,
695
,
GenericIPAddressPKData
,
"fe80:1424:2223:6cff:fe8a:2e8a:2151:abcd"
),
# (pk_obj, 700, NullBooleanPKData, True),
# (pk_obj, 700, NullBooleanPKData, True),
# (pk_obj, 701, NullBooleanPKData, False),
# (pk_obj, 701, NullBooleanPKData, False),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment