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
c24a2e6c
Kaydet (Commit)
c24a2e6c
authored
Kas 13, 2014
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23765 -- Removed BooleanField default check which often yielded false positives.
üst
d5a109f6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
3 additions
and
77 deletions
+3
-77
__init__.py
django/core/checks/__init__.py
+0
-1
django_1_6_0.py
django/core/checks/compatibility/django_1_6_0.py
+0
-41
checks.txt
docs/ref/checks.txt
+2
-1
models.py
tests/check_framework/models.py
+0
-5
tests.py
tests/check_framework/tests.py
+1
-29
No files found.
django/core/checks/__init__.py
Dosyayı görüntüle @
c24a2e6c
...
...
@@ -7,7 +7,6 @@ from .messages import (CheckMessage,
from
.registry
import
register
,
run_checks
,
tag_exists
,
Tags
# Import these to force registration of checks
import
django.core.checks.compatibility.django_1_6_0
# NOQA
import
django.core.checks.compatibility.django_1_7_0
# NOQA
import
django.core.checks.model_checks
# NOQA
import
django.core.checks.security.base
# NOQA
...
...
django/core/checks/compatibility/django_1_6_0.py
deleted
100644 → 0
Dosyayı görüntüle @
d5a109f6
# -*- encoding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.apps
import
apps
from
..
import
Warning
,
register
,
Tags
@register
(
Tags
.
compatibility
)
def
check_1_6_compatibility
(
**
kwargs
):
errors
=
[]
errors
.
extend
(
_check_boolean_field_default_value
(
**
kwargs
))
return
errors
def
_check_boolean_field_default_value
(
app_configs
=
None
,
**
kwargs
):
"""
Checks if there are any BooleanFields without a default value, &
warns the user that the default has changed from False to None.
"""
from
django.db
import
models
problem_fields
=
[
field
for
model
in
apps
.
get_models
(
**
kwargs
)
if
app_configs
is
None
or
model
.
_meta
.
app_config
in
app_configs
for
field
in
model
.
_meta
.
local_fields
if
isinstance
(
field
,
models
.
BooleanField
)
and
not
field
.
has_default
()
]
return
[
Warning
(
"BooleanField does not have a default value."
,
hint
=
(
"Django 1.6 changed the default value of BooleanField from False to None. "
"See https://docs.djangoproject.com/en/1.6/ref/models/fields/#booleanfield "
"for more information."
),
obj
=
field
,
id
=
'1_6.W002'
,
)
for
field
in
problem_fields
]
docs/ref/checks.txt
Dosyayı görüntüle @
c24a2e6c
...
...
@@ -168,7 +168,8 @@ that might occur as a result of a version upgrade.
* **1_6.W001**: Some project unit tests may not execute as expected. *This
check was removed in Django 1.8 due to false positives*.
* **1_6.W002**: ``BooleanField`` does not have a default value.
* **1_6.W002**: ``BooleanField`` does not have a default value. *This
check was removed in Django 1.8 due to false positives*.
* **1_7.W001**: Django 1.7 changed the global defaults for the
``MIDDLEWARE_CLASSES.``
``django.contrib.sessions.middleware.SessionMiddleware``,
...
...
tests/check_framework/models.py
Dosyayı görüntüle @
c24a2e6c
...
...
@@ -7,8 +7,3 @@ from django.db import models
class
SimpleModel
(
models
.
Model
):
field
=
models
.
IntegerField
()
manager
=
models
.
manager
.
Manager
()
class
Book
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
250
)
is_published
=
models
.
BooleanField
(
default
=
False
)
tests/check_framework/tests.py
Dosyayı görüntüle @
c24a2e6c
...
...
@@ -10,17 +10,15 @@ from django.core import checks
from
django.core.checks
import
Error
,
Warning
from
django.core.checks.model_checks
import
check_all_models
from
django.core.checks.registry
import
CheckRegistry
from
django.core.checks.compatibility.django_1_6_0
import
check_1_6_compatibility
from
django.core.checks.compatibility.django_1_7_0
import
check_1_7_compatibility
from
django.core.management.base
import
CommandError
from
django.core.management
import
call_command
from
django.db
import
models
from
django.db.models.fields
import
NOT_PROVIDED
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
,
override_system_checks
from
django.utils.encoding
import
force_text
from
.models
import
SimpleModel
,
Book
from
.models
import
SimpleModel
class
DummyObj
(
object
):
...
...
@@ -114,32 +112,6 @@ class MessageTests(TestCase):
self
.
assertEqual
(
force_text
(
e
),
expected
)
class
Django_1_6_0_CompatibilityChecks
(
TestCase
):
@override_settings
(
TEST_RUNNER
=
'myapp.test.CustomRunner'
)
def
test_boolean_field_default_value
(
self
):
# We patch the field's default value to trigger the warning
boolean_field
=
Book
.
_meta
.
get_field
(
'is_published'
)
old_default
=
boolean_field
.
default
try
:
boolean_field
.
default
=
NOT_PROVIDED
errors
=
check_1_6_compatibility
()
expected
=
[
checks
.
Warning
(
'BooleanField does not have a default value.'
,
hint
=
(
'Django 1.6 changed the default value of BooleanField from False to None. '
'See https://docs.djangoproject.com/en/1.6/ref/models/fields/#booleanfield '
'for more information.'
),
obj
=
boolean_field
,
id
=
'1_6.W002'
,
)
]
self
.
assertEqual
(
errors
,
expected
)
finally
:
# Restore the ``default``
boolean_field
.
default
=
old_default
class
Django_1_7_0_CompatibilityChecks
(
TestCase
):
@override_settings
(
MIDDLEWARE_CLASSES
=
(
'django.contrib.sessions.middleware.SessionMiddleware'
,))
...
...
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