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
d3e12c90
Kaydet (Commit)
d3e12c90
authored
Haz 23, 2015
tarafından
薛丞宏
Kaydeden (comit)
Tim Graham
Haz 26, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25016 -- Reallowed non-ASCII values for ForeignKey.related_name on Python 3.
üst
60879a21
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
6 deletions
+25
-6
related.py
django/db/models/fields/related.py
+12
-4
1.8.3.txt
docs/releases/1.8.3.txt
+3
-0
spelling_wordlist
docs/spelling_wordlist
+1
-0
test_relative_fields.py
tests/invalid_models_tests/test_relative_fields.py
+9
-2
No files found.
django/db/models/fields/related.py
Dosyayı görüntüle @
d3e12c90
...
...
@@ -119,10 +119,18 @@ class RelatedField(Field):
import
re
import
keyword
related_name
=
self
.
remote_field
.
related_name
is_valid_id
=
(
related_name
and
re
.
match
(
'^[a-zA-Z_][a-zA-Z0-9_]*$'
,
related_name
)
and
not
keyword
.
iskeyword
(
related_name
))
if
related_name
and
not
(
is_valid_id
or
related_name
.
endswith
(
'+'
)):
if
not
related_name
:
return
[]
is_valid_id
=
True
if
keyword
.
iskeyword
(
related_name
):
is_valid_id
=
False
if
six
.
PY3
:
if
not
related_name
.
isidentifier
():
is_valid_id
=
False
else
:
if
not
re
.
match
(
r'^[a-zA-Z_][a-zA-Z0-9_]*\Z'
,
related_name
):
is_valid_id
=
False
if
not
(
is_valid_id
or
related_name
.
endswith
(
'+'
)):
return
[
checks
.
Error
(
"The name '
%
s' is invalid related_name for field
%
s.
%
s"
%
...
...
docs/releases/1.8.3.txt
Dosyayı görüntüle @
d3e12c90
...
...
@@ -82,3 +82,6 @@ Bugfixes
* Fixed a regression when deleting a model through the admin that has a
``GenericRelation`` with a ``related_query_name`` (:ticket:`24940`).
* Reallowed non-ASCII values for ``ForeignKey.related_name`` on Python 3 by
fixing the false positive system check (:ticket:`25016`).
docs/spelling_wordlist
Dosyayı görüntüle @
d3e12c90
...
...
@@ -625,6 +625,7 @@ quo
quoteless
Radziej
rc
reallowed
rebase
rebased
rebasing
...
...
tests/invalid_models_tests/test_relative_fields.py
Dosyayı görüntüle @
d3e12c90
...
...
@@ -5,6 +5,7 @@ from django.core.checks import Error, Warning as DjangoWarning
from
django.db
import
models
from
django.test.testcases
import
skipIfDBFeature
from
django.test.utils
import
override_settings
from
django.utils
import
six
from
.base
import
IsolatedModelsTestCase
...
...
@@ -559,9 +560,12 @@ class RelativeFieldTests(IsolatedModelsTestCase):
'contains_
%
s_whitespace'
%
whitespace
,
'ends_with_with_illegal_non_alphanumeric_
%
s'
%
illegal_non_alphanumeric
,
'ends_with_whitespace_
%
s'
%
whitespace
,
# Python's
keyword
'
with
'
,
'with'
,
# a Python
keyword
'
related_name
\n
'
,
]
# Python 2 crashes on non-ASCII strings.
if
six
.
PY3
:
invalid_related_names
.
append
(
','
)
class
Parent
(
models
.
Model
):
pass
...
...
@@ -600,6 +604,9 @@ class RelativeFieldTests(IsolatedModelsTestCase):
'_+'
,
'+'
,
]
# Python 2 crashes on non-ASCII strings.
if
six
.
PY3
:
related_names
.
extend
([
'試'
,
'試驗+'
])
class
Parent
(
models
.
Model
):
pass
...
...
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