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
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
68 additions
and
12 deletions
+68
-12
__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
+4
-1
test_error_messages.py
tests/forms_tests/tests/test_error_messages.py
+5
-1
test_extra.py
tests/forms_tests/tests/test_extra.py
+7
-2
models.py
tests/inspectdb/models.py
+4
-1
models.py
tests/model_fields/models.py
+4
-1
tests.py
tests/model_fields/tests.py
+6
-3
models.py
tests/serializers_regress/models.py
+7
-2
models.py
tests/string_lookup/models.py
+4
-1
No files found.
django/db/models/fields/__init__.py
Dosyayı görüntüle @
1a630929
...
...
@@ -1312,6 +1312,8 @@ class IPAddressField(Field):
description
=
_
(
"IPv4 address"
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
warnings
.
warn
(
"IPAddressField has been deprecated. Use GenericIPAddressField instead."
,
PendingDeprecationWarning
)
kwargs
[
'max_length'
]
=
15
Field
.
__init__
(
self
,
*
args
,
**
kwargs
)
...
...
django/forms/fields.py
Dosyayı görüntüle @
1a630929
...
...
@@ -9,6 +9,7 @@ import datetime
import
os
import
re
import
sys
import
warnings
from
decimal
import
Decimal
,
DecimalException
from
io
import
BytesIO
...
...
@@ -1144,6 +1145,11 @@ class SplitDateTimeField(MultiValueField):
class
IPAddressField
(
CharField
):
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
):
if
value
in
self
.
empty_values
:
return
''
...
...
docs/internals/deprecation.txt
Dosyayı görüntüle @
1a630929
...
...
@@ -436,6 +436,8 @@ these changes.
:ref:`initial SQL data<initial-sql>` in ``myapp/models/sql/``. Move your
custom SQL files to ``myapp/sql/``.
* The model and form ``IPAddressField`` will be removed.
* FastCGI support via the ``runfcgi`` management command will be
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
.. class:: IPAddressField(**kwargs)
.. deprecated:: 1.7
This field has been deprecated in favour of
:class:`~django.forms.GenericIPAddressField`.
* Default widget: :class:`TextInput`
* Empty value: ``''`` (an empty string)
* 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
.. 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
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:
``ModelAdmin.get_formsets`` has been deprecated in favor of the new
:meth:`~django.contrib.admin.ModelAdmin.get_formsets_with_inlines`, in order to
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.db
import
models
...
...
@@ -173,7 +174,9 @@ class FieldDeconstructionTests(TestCase):
self
.
assertEqual
(
kwargs
,
{})
def
test_ip_address_field
(
self
):
field
=
models
.
IPAddressField
()
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
field
=
models
.
IPAddressField
()
name
,
path
,
args
,
kwargs
=
field
.
deconstruct
()
self
.
assertEqual
(
path
,
"django.db.models.IPAddressField"
)
self
.
assertEqual
(
args
,
[])
...
...
tests/forms_tests/tests/test_error_messages.py
Dosyayı görüntüle @
1a630929
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
warnings
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
django.forms
import
*
from
django.test
import
TestCase
...
...
@@ -192,7 +194,9 @@ class FormsErrorMessagesTestCase(TestCase, AssertFormErrorsMixin):
'required'
:
'REQUIRED'
,
'invalid'
:
'INVALID IP ADDRESS'
,
}
f
=
IPAddressField
(
error_messages
=
e
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
f
=
IPAddressField
(
error_messages
=
e
)
self
.
assertFormErrors
([
'REQUIRED'
],
f
.
clean
,
''
)
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 @@
from
__future__
import
unicode_literals
import
datetime
import
warnings
from
django.forms
import
*
from
django.forms.extras
import
SelectDateWidget
...
...
@@ -535,7 +536,9 @@ class FormsExtraTestCase(TestCase, AssertFormErrorsMixin):
self
.
assertEqual
(
f
.
cleaned_data
[
'field1'
],
'some text,JP,2007-04-25 06:24:00'
)
def
test_ipaddress
(
self
):
f
=
IPAddressField
()
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
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'
)
...
...
@@ -544,7 +547,9 @@ 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
,
'256.125.1.5'
)
f
=
IPAddressField
(
required
=
False
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
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'
)
...
...
tests/inspectdb/models.py
Dosyayı görüntüle @
1a630929
# -*- encoding: utf-8 -*-
from
__future__
import
unicode_literals
import
warnings
from
django.db
import
models
...
...
@@ -49,7 +50,9 @@ class ColumnTypes(models.Model):
file_path_field
=
models
.
FilePathField
()
float_field
=
models
.
FloatField
()
int_field
=
models
.
IntegerField
()
ip_address_field
=
models
.
IPAddressField
()
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
ip_address_field
=
models
.
IPAddressField
()
gen_ip_adress_field
=
models
.
GenericIPAddressField
(
protocol
=
"ipv4"
)
pos_int_field
=
models
.
PositiveIntegerField
()
pos_small_int_field
=
models
.
PositiveSmallIntegerField
()
...
...
tests/model_fields/models.py
Dosyayı görüntüle @
1a630929
import
os
import
tempfile
import
warnings
from
django.core.exceptions
import
ImproperlyConfigured
...
...
@@ -85,7 +86,9 @@ class VerboseNameField(models.Model):
# Don't want to depend on Pillow/PIL in this test
#field_image = models.ImageField("verbose field")
field12
=
models
.
IntegerField
(
"verbose field12"
)
field13
=
models
.
IPAddressField
(
"verbose field13"
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
field13
=
models
.
IPAddressField
(
"verbose field13"
)
field14
=
models
.
GenericIPAddressField
(
"verbose field14"
,
protocol
=
"ipv4"
)
field15
=
models
.
NullBooleanField
(
"verbose field15"
)
field16
=
models
.
PositiveIntegerField
(
"verbose field16"
)
...
...
tests/model_fields/tests.py
Dosyayı görüntüle @
1a630929
...
...
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
import
datetime
from
decimal
import
Decimal
import
unittest
import
warnings
from
django
import
test
from
django
import
forms
...
...
@@ -603,9 +604,11 @@ class PromiseTest(test.TestCase):
def
test_IPAddressField
(
self
):
lazy_func
=
lazy
(
lambda
:
'127.0.0.1'
,
six
.
text_type
)
self
.
assertIsInstance
(
IPAddressField
()
.
get_prep_value
(
lazy_func
()),
six
.
text_type
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
self
.
assertIsInstance
(
IPAddressField
()
.
get_prep_value
(
lazy_func
()),
six
.
text_type
)
def
test_GenericIPAddressField
(
self
):
lazy_func
=
lazy
(
lambda
:
'127.0.0.1'
,
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.
This class sets up a model for each model field type
(except for image types, because of the Pillow/PIL dependency).
"""
import
warnings
from
django.db
import
models
from
django.contrib.contenttypes
import
generic
...
...
@@ -52,7 +53,9 @@ class BigIntegerData(models.Model):
# data = models.ImageField(null=True)
class
IPAddressData
(
models
.
Model
):
data
=
models
.
IPAddressField
(
null
=
True
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
data
=
models
.
IPAddressField
(
null
=
True
)
class
GenericIPAddressData
(
models
.
Model
):
data
=
models
.
GenericIPAddressField
(
null
=
True
)
...
...
@@ -199,7 +202,9 @@ class IntegerPKData(models.Model):
# data = models.ImageField(primary_key=True)
class
IPAddressPKData
(
models
.
Model
):
data
=
models
.
IPAddressField
(
primary_key
=
True
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
data
=
models
.
IPAddressField
(
primary_key
=
True
)
class
GenericIPAddressPKData
(
models
.
Model
):
data
=
models
.
GenericIPAddressField
(
primary_key
=
True
)
...
...
tests/string_lookup/models.py
Dosyayı görüntüle @
1a630929
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
import
warnings
from
django.db
import
models
from
django.utils.encoding
import
python_2_unicode_compatible
...
...
@@ -49,7 +50,9 @@ class Base(models.Model):
class
Article
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
text
=
models
.
TextField
()
submitted_from
=
models
.
IPAddressField
(
blank
=
True
,
null
=
True
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
simplefilter
(
"always"
)
submitted_from
=
models
.
IPAddressField
(
blank
=
True
,
null
=
True
)
def
__str__
(
self
):
return
"Article
%
s"
%
self
.
name
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