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
aadd3aeb
Kaydet (Commit)
aadd3aeb
authored
Tem 31, 2017
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Tem 31, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Avoided creating temporary lists for obtaining the first item.
üst
0f905e4b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
17 additions
and
19 deletions
+17
-19
loader.py
django/db/migrations/loader.py
+2
-2
questioner.py
django/db/migrations/questioner.py
+1
-1
base.py
django/db/models/base.py
+2
-2
query.py
django/db/models/query.py
+6
-9
query.py
django/db/models/sql/query.py
+2
-1
utils.py
django/forms/utils.py
+2
-2
i18n.py
django/templatetags/i18n.py
+1
-1
tests.py
tests/get_earliest_or_latest/tests.py
+1
-1
No files found.
django/db/migrations/loader.py
Dosyayı görüntüle @
aadd3aeb
...
...
@@ -156,9 +156,9 @@ class MigrationLoader:
if
key
[
0
]
in
self
.
migrated_apps
:
try
:
if
key
[
1
]
==
"__first__"
:
return
list
(
self
.
graph
.
root_nodes
(
key
[
0
])
)[
0
]
return
self
.
graph
.
root_nodes
(
key
[
0
]
)[
0
]
else
:
# "__latest__"
return
list
(
self
.
graph
.
leaf_nodes
(
key
[
0
])
)[
0
]
return
self
.
graph
.
leaf_nodes
(
key
[
0
]
)[
0
]
except
IndexError
:
if
self
.
ignore_no_migrations
:
return
None
...
...
django/db/migrations/questioner.py
Dosyayı görüntüle @
aadd3aeb
...
...
@@ -48,7 +48,7 @@ class MigrationQuestioner:
elif
hasattr
(
migrations_module
,
"__path__"
):
if
len
(
migrations_module
.
__path__
)
>
1
:
return
False
filenames
=
os
.
listdir
(
list
(
migrations_module
.
__path__
)
[
0
])
filenames
=
os
.
listdir
(
migrations_module
.
__path__
[
0
])
return
not
any
(
x
.
endswith
(
".py"
)
for
x
in
filenames
if
x
!=
"__init__.py"
)
def
ask_not_null_addition
(
self
,
field_name
,
model_name
):
...
...
django/db/models/base.py
Dosyayı görüntüle @
aadd3aeb
...
...
@@ -481,8 +481,8 @@ class Model(metaclass=ModelBase):
del
kwargs
[
prop
]
except
(
AttributeError
,
FieldDoesNotExist
):
pass
if
kwargs
:
raise
TypeError
(
"'
%
s' is an invalid keyword argument for this function"
%
list
(
kwargs
)[
0
]
)
for
kwarg
in
kwargs
:
raise
TypeError
(
"'
%
s' is an invalid keyword argument for this function"
%
kwarg
)
super
()
.
__init__
()
post_init
.
send
(
sender
=
cls
,
instance
=
self
)
...
...
django/db/models/query.py
Dosyayı görüntüle @
aadd3aeb
...
...
@@ -275,7 +275,8 @@ class QuerySet:
qs
=
self
.
_clone
()
qs
.
query
.
set_limits
(
k
,
k
+
1
)
return
list
(
qs
)[
0
]
qs
.
_fetch_all
()
return
qs
.
_result_cache
[
0
]
def
__and__
(
self
,
other
):
self
.
_merge_sanity_check
(
other
)
...
...
@@ -548,17 +549,13 @@ class QuerySet:
def
first
(
self
):
"""Return the first object of a query or None if no match is found."""
objects
=
list
((
self
if
self
.
ordered
else
self
.
order_by
(
'pk'
))[:
1
])
if
objects
:
return
objects
[
0
]
return
None
for
obj
in
(
self
if
self
.
ordered
else
self
.
order_by
(
'pk'
))[:
1
]:
return
obj
def
last
(
self
):
"""Return the last object of a query or None if no match is found."""
objects
=
list
((
self
.
reverse
()
if
self
.
ordered
else
self
.
order_by
(
'-pk'
))[:
1
])
if
objects
:
return
objects
[
0
]
return
None
for
obj
in
(
self
.
reverse
()
if
self
.
ordered
else
self
.
order_by
(
'-pk'
))[:
1
]:
return
obj
def
in_bulk
(
self
,
id_list
=
None
,
*
,
field_name
=
'pk'
):
"""
...
...
django/db/models/sql/query.py
Dosyayı görüntüle @
aadd3aeb
...
...
@@ -217,7 +217,8 @@ class Query:
@cached_property
def
base_table
(
self
):
return
list
(
self
.
alias_map
)[
0
]
if
self
.
alias_map
else
None
for
alias
in
self
.
alias_map
:
return
alias
def
__str__
(
self
):
"""
...
...
django/forms/utils.py
Dosyayı görüntüle @
aadd3aeb
...
...
@@ -95,7 +95,7 @@ class ErrorList(UserList, list):
def
get_json_data
(
self
,
escape_html
=
False
):
errors
=
[]
for
error
in
self
.
as_data
():
message
=
list
(
error
)[
0
]
message
=
next
(
iter
(
error
))
errors
.
append
({
'message'
:
escape
(
message
)
if
escape_html
else
message
,
'code'
:
error
.
code
or
''
,
...
...
@@ -133,7 +133,7 @@ class ErrorList(UserList, list):
def
__getitem__
(
self
,
i
):
error
=
self
.
data
[
i
]
if
isinstance
(
error
,
ValidationError
):
return
list
(
error
)[
0
]
return
next
(
iter
(
error
))
return
error
def
__reduce_ex__
(
self
,
*
args
,
**
kwargs
):
...
...
django/templatetags/i18n.py
Dosyayı görüntüle @
aadd3aeb
...
...
@@ -500,7 +500,7 @@ def do_block_translate(parser, token):
options
[
option
]
=
value
if
'count'
in
options
:
countervar
,
counter
=
list
(
options
[
'count'
]
.
items
())[
0
]
countervar
,
counter
=
next
(
iter
(
options
[
'count'
]
.
items
()))
else
:
countervar
,
counter
=
None
,
None
if
'context'
in
options
:
...
...
tests/get_earliest_or_latest/tests.py
Dosyayı görüntüle @
aadd3aeb
...
...
@@ -155,7 +155,7 @@ class TestFirstLast(TestCase):
# We know that we've broken the __iter__ method, so the queryset
# should always raise an exception.
with
self
.
assertRaises
(
IndexError
):
IndexErrorArticle
.
objects
.
all
()[
0
]
IndexErrorArticle
.
objects
.
all
()[
:
10
:
2
]
with
self
.
assertRaises
(
IndexError
):
IndexErrorArticle
.
objects
.
all
()
.
first
()
with
self
.
assertRaises
(
IndexError
):
...
...
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