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
1a630929
Kaydet (Commit)
1a630929
authored
Eyl 28, 2013
tarafından
Erik Romijn
Kaydeden (comit)
Aymeric Augustin
Eyl 28, 2013
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #20439 -- Started deprecation of IPAddressField
üst
8f51ba66
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
56 additions
and
0 deletions
+56
-0
__init__.py
django/db/models/fields/__init__.py
+2
-0
fields.py
django/forms/fields.py
+6
-0
deprecation.txt
docs/internals/deprecation.txt
+2
-0
fields.txt
docs/ref/forms/fields.txt
+4
-0
fields.txt
docs/ref/models/fields.txt
+4
-0
1.7.txt
docs/releases/1.7.txt
+9
-0
tests.py
tests/field_deconstruction/tests.py
+3
-0
test_error_messages.py
tests/forms_tests/tests/test_error_messages.py
+4
-0
test_extra.py
tests/forms_tests/tests/test_extra.py
+5
-0
models.py
tests/inspectdb/models.py
+3
-0
models.py
tests/model_fields/models.py
+3
-0
tests.py
tests/model_fields/tests.py
+3
-0
models.py
tests/serializers_regress/models.py
+5
-0
models.py
tests/string_lookup/models.py
+3
-0
No files found.
django/db/models/fields/__init__.py
Dosyayı görüntüle @
1a630929
...
@@ -1312,6 +1312,8 @@ class IPAddressField(Field):
...
@@ -1312,6 +1312,8 @@ class IPAddressField(Field):
description
=
_
(
"IPv4 address"
)
description
=
_
(
"IPv4 address"
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
warnings
.
warn
(
"IPAddressField has been deprecated. Use GenericIPAddressField instead."
,
PendingDeprecationWarning
)
kwargs
[
'max_length'
]
=
15
kwargs
[
'max_length'
]
=
15
Field
.
__init__
(
self
,
*
args
,
**
kwargs
)
Field
.
__init__
(
self
,
*
args
,
**
kwargs
)
...
...
django/forms/fields.py
Dosyayı görüntüle @
1a630929
...
@@ -9,6 +9,7 @@ import datetime
...
@@ -9,6 +9,7 @@ import datetime
import
os
import
os
import
re
import
re
import
sys
import
sys
import
warnings
from
decimal
import
Decimal
,
DecimalException
from
decimal
import
Decimal
,
DecimalException
from
io
import
BytesIO
from
io
import
BytesIO
...
@@ -1144,6 +1145,11 @@ class SplitDateTimeField(MultiValueField):
...
@@ -1144,6 +1145,11 @@ class SplitDateTimeField(MultiValueField):
class
IPAddressField
(
CharField
):
class
IPAddressField
(
CharField
):
default_validators
=
[
validators
.
validate_ipv4_address
]
default_validators
=
[
validators
.
validate_ipv4_address
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
warnings
.
warn
(
"IPAddressField has been deprecated. Use GenericIPAddressField instead."
,
PendingDeprecationWarning
)
super
(
IPAddressField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
to_python
(
self
,
value
):
def
to_python
(
self
,
value
):
if
value
in
self
.
empty_values
:
if
value
in
self
.
empty_values
:
return
''
return
''
...
...
docs/internals/deprecation.txt
Dosyayı görüntüle @
1a630929
...
@@ -436,6 +436,8 @@ these changes.
...
@@ -436,6 +436,8 @@ these changes.
:ref:`initial SQL data<initial-sql>` in ``myapp/models/sql/``. Move your
:ref:`initial SQL data<initial-sql>` in ``myapp/models/sql/``. Move your
custom SQL files to ``myapp/sql/``.
custom SQL files to ``myapp/sql/``.
* The model and form ``IPAddressField`` will be removed.
* FastCGI support via the ``runfcgi`` management command will be
* FastCGI support via the ``runfcgi`` management command will be
removed. Please deploy your project using WSGI.
removed. Please deploy your project using WSGI.
...
...
docs/ref/forms/fields.txt
Dosyayı görüntüle @
1a630929
...
@@ -657,6 +657,10 @@ For each field, we describe the default widget used if you don't specify
...
@@ -657,6 +657,10 @@ For each field, we describe the default widget used if you don't specify
.. class:: IPAddressField(**kwargs)
.. class:: IPAddressField(**kwargs)
.. deprecated:: 1.7
This field has been deprecated in favour of
:class:`~django.forms.GenericIPAddressField`.
* Default widget: :class:`TextInput`
* Default widget: :class:`TextInput`
* Empty value: ``''`` (an empty string)
* Empty value: ``''`` (an empty string)
* Normalizes to: A Unicode object.
* Normalizes to: A Unicode object.
...
...
docs/ref/models/fields.txt
Dosyayı görüntüle @
1a630929
...
@@ -849,6 +849,10 @@ An integer. The default form widget for this field is a
...
@@ -849,6 +849,10 @@ An integer. The default form widget for this field is a
.. class:: IPAddressField([**options])
.. class:: IPAddressField([**options])
.. deprecated:: 1.7
This field has been deprecated in favour of
:class:`~django.db.models.GenericIPAddressField`.
An IP address, in string format (e.g. "192.0.2.30"). The default form widget
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`.
for this field is a :class:`~django.forms.TextInput`.
...
...
docs/releases/1.7.txt
Dosyayı görüntüle @
1a630929
...
@@ -529,3 +529,12 @@ to ``utils.py`` in an effort to unify all util and utils references:
...
@@ -529,3 +529,12 @@ to ``utils.py`` in an effort to unify all util and utils references:
``ModelAdmin.get_formsets`` has been deprecated in favor of the new
``ModelAdmin.get_formsets`` has been deprecated in favor of the new
:meth:`~django.contrib.admin.ModelAdmin.get_formsets_with_inlines`, in order to
:meth:`~django.contrib.admin.ModelAdmin.get_formsets_with_inlines`, in order to
better handle the case of selecting showing inlines on a ``ModelAdmin``.
better handle the case of selecting showing inlines on a ``ModelAdmin``.
``IPAddressField``
~~~~~~~~~~~~~~~~~~
The :class:`django.db.models.IPAddressField` and
:class:`django.forms.IPAddressField` fields have been deprecated in favor of
:class:`django.db.models.GenericIPAddressField` and
:class:`django.forms.GenericIPAddressField`.
tests/field_deconstruction/tests.py
Dosyayı görüntüle @
1a630929
import
warnings
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.db
import
models
from
django.db
import
models
...
@@ -173,6 +174,8 @@ class FieldDeconstructionTests(TestCase):
...
@@ -173,6 +174,8 @@ class FieldDeconstructionTests(TestCase):
self
.
assertEqual
(
kwargs
,
{})
self
.
assertEqual
(
kwargs
,
{})
def
test_ip_address_field
(
self
):
def
test_ip_address_field
(
self
):
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
field
=
models
.
IPAddressField
()
field
=
models
.
IPAddressField
()
name
,
path
,
args
,
kwargs
=
field
.
deconstruct
()
name
,
path
,
args
,
kwargs
=
field
.
deconstruct
()
self
.
assertEqual
(
path
,
"django.db.models.IPAddressField"
)
self
.
assertEqual
(
path
,
"django.db.models.IPAddressField"
)
...
...
tests/forms_tests/tests/test_error_messages.py
Dosyayı görüntüle @
1a630929
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
warnings
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
django.forms
import
*
from
django.forms
import
*
from
django.test
import
TestCase
from
django.test
import
TestCase
...
@@ -192,6 +194,8 @@ class FormsErrorMessagesTestCase(TestCase, AssertFormErrorsMixin):
...
@@ -192,6 +194,8 @@ class FormsErrorMessagesTestCase(TestCase, AssertFormErrorsMixin):
'required'
:
'REQUIRED'
,
'required'
:
'REQUIRED'
,
'invalid'
:
'INVALID IP ADDRESS'
,
'invalid'
:
'INVALID IP ADDRESS'
,
}
}
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
f
=
IPAddressField
(
error_messages
=
e
)
f
=
IPAddressField
(
error_messages
=
e
)
self
.
assertFormErrors
([
'REQUIRED'
],
f
.
clean
,
''
)
self
.
assertFormErrors
([
'REQUIRED'
],
f
.
clean
,
''
)
self
.
assertFormErrors
([
'INVALID IP ADDRESS'
],
f
.
clean
,
'127.0.0'
)
self
.
assertFormErrors
([
'INVALID IP ADDRESS'
],
f
.
clean
,
'127.0.0'
)
...
...
tests/forms_tests/tests/test_extra.py
Dosyayı görüntüle @
1a630929
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
datetime
import
datetime
import
warnings
from
django.forms
import
*
from
django.forms
import
*
from
django.forms.extras
import
SelectDateWidget
from
django.forms.extras
import
SelectDateWidget
...
@@ -535,6 +536,8 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
...
@@ -535,6 +536,8 @@ 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'
)
def
test_ipaddress
(
self
):
def
test_ipaddress
(
self
):
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
f
=
IPAddressField
()
f
=
IPAddressField
()
self
.
assertFormErrors
([
'This field is required.'
],
f
.
clean
,
''
)
self
.
assertFormErrors
([
'This field is required.'
],
f
.
clean
,
''
)
self
.
assertFormErrors
([
'This field is required.'
],
f
.
clean
,
None
)
self
.
assertFormErrors
([
'This field is required.'
],
f
.
clean
,
None
)
...
@@ -544,6 +547,8 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
...
@@ -544,6 +547,8 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
self
.
assertFormErrors
([
'Enter a valid IPv4 address.'
],
f
.
clean
,
'1.2.3.4.5'
)
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'
)
self
.
assertFormErrors
([
'Enter a valid IPv4 address.'
],
f
.
clean
,
'256.125.1.5'
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
f
=
IPAddressField
(
required
=
False
)
f
=
IPAddressField
(
required
=
False
)
self
.
assertEqual
(
f
.
clean
(
''
),
''
)
self
.
assertEqual
(
f
.
clean
(
''
),
''
)
self
.
assertEqual
(
f
.
clean
(
None
),
''
)
self
.
assertEqual
(
f
.
clean
(
None
),
''
)
...
...
tests/inspectdb/models.py
Dosyayı görüntüle @
1a630929
# -*- encoding: utf-8 -*-
# -*- encoding: utf-8 -*-
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
warnings
from
django.db
import
models
from
django.db
import
models
...
@@ -49,6 +50,8 @@ class ColumnTypes(models.Model):
...
@@ -49,6 +50,8 @@ 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
()
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
ip_address_field
=
models
.
IPAddressField
()
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
()
...
...
tests/model_fields/models.py
Dosyayı görüntüle @
1a630929
import
os
import
os
import
tempfile
import
tempfile
import
warnings
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.exceptions
import
ImproperlyConfigured
...
@@ -85,6 +86,8 @@ class VerboseNameField(models.Model):
...
@@ -85,6 +86,8 @@ class VerboseNameField(models.Model):
# Don't want to depend on Pillow/PIL in this test
# Don't want to depend on Pillow/PIL 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"
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
field13
=
models
.
IPAddressField
(
"verbose field13"
)
field13
=
models
.
IPAddressField
(
"verbose field13"
)
field14
=
models
.
GenericIPAddressField
(
"verbose field14"
,
protocol
=
"ipv4"
)
field14
=
models
.
GenericIPAddressField
(
"verbose field14"
,
protocol
=
"ipv4"
)
field15
=
models
.
NullBooleanField
(
"verbose field15"
)
field15
=
models
.
NullBooleanField
(
"verbose field15"
)
...
...
tests/model_fields/tests.py
Dosyayı görüntüle @
1a630929
...
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
...
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
import
datetime
import
datetime
from
decimal
import
Decimal
from
decimal
import
Decimal
import
unittest
import
unittest
import
warnings
from
django
import
test
from
django
import
test
from
django
import
forms
from
django
import
forms
...
@@ -603,6 +604,8 @@ class PromiseTest(test.TestCase):
...
@@ -603,6 +604,8 @@ class PromiseTest(test.TestCase):
def
test_IPAddressField
(
self
):
def
test_IPAddressField
(
self
):
lazy_func
=
lazy
(
lambda
:
'127.0.0.1'
,
six
.
text_type
)
lazy_func
=
lazy
(
lambda
:
'127.0.0.1'
,
six
.
text_type
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
self
.
assertIsInstance
(
self
.
assertIsInstance
(
IPAddressField
()
.
get_prep_value
(
lazy_func
()),
IPAddressField
()
.
get_prep_value
(
lazy_func
()),
six
.
text_type
)
six
.
text_type
)
...
...
tests/serializers_regress/models.py
Dosyayı görüntüle @
1a630929
...
@@ -4,6 +4,7 @@ A test spanning all the capabilities of all the serializers.
...
@@ -4,6 +4,7 @@ A test spanning all the capabilities of all the serializers.
This class sets up a model for each model field type
This class sets up a model for each model field type
(except for image types, because of the Pillow/PIL dependency).
(except for image types, because of the Pillow/PIL dependency).
"""
"""
import
warnings
from
django.db
import
models
from
django.db
import
models
from
django.contrib.contenttypes
import
generic
from
django.contrib.contenttypes
import
generic
...
@@ -52,6 +53,8 @@ class BigIntegerData(models.Model):
...
@@ -52,6 +53,8 @@ class BigIntegerData(models.Model):
# data = models.ImageField(null=True)
# data = models.ImageField(null=True)
class
IPAddressData
(
models
.
Model
):
class
IPAddressData
(
models
.
Model
):
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
data
=
models
.
IPAddressField
(
null
=
True
)
data
=
models
.
IPAddressField
(
null
=
True
)
class
GenericIPAddressData
(
models
.
Model
):
class
GenericIPAddressData
(
models
.
Model
):
...
@@ -199,6 +202,8 @@ class IntegerPKData(models.Model):
...
@@ -199,6 +202,8 @@ class IntegerPKData(models.Model):
# data = models.ImageField(primary_key=True)
# data = models.ImageField(primary_key=True)
class
IPAddressPKData
(
models
.
Model
):
class
IPAddressPKData
(
models
.
Model
):
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
data
=
models
.
IPAddressField
(
primary_key
=
True
)
data
=
models
.
IPAddressField
(
primary_key
=
True
)
class
GenericIPAddressPKData
(
models
.
Model
):
class
GenericIPAddressPKData
(
models
.
Model
):
...
...
tests/string_lookup/models.py
Dosyayı görüntüle @
1a630929
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
warnings
from
django.db
import
models
from
django.db
import
models
from
django.utils.encoding
import
python_2_unicode_compatible
from
django.utils.encoding
import
python_2_unicode_compatible
...
@@ -49,6 +50,8 @@ class Base(models.Model):
...
@@ -49,6 +50,8 @@ class Base(models.Model):
class
Article
(
models
.
Model
):
class
Article
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
name
=
models
.
CharField
(
max_length
=
50
)
text
=
models
.
TextField
()
text
=
models
.
TextField
()
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
submitted_from
=
models
.
IPAddressField
(
blank
=
True
,
null
=
True
)
submitted_from
=
models
.
IPAddressField
(
blank
=
True
,
null
=
True
)
def
__str__
(
self
):
def
__str__
(
self
):
...
...
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