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
b3b47bf5
Kaydet (Commit)
b3b47bf5
authored
Eki 01, 2018
tarafından
Jon Dufresne
Kaydeden (comit)
Tim Graham
Eki 01, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added tests for using bytearray with BinaryField and corrected docs.
üst
e9defb3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
fields.txt
docs/ref/models/fields.txt
+2
-2
test_binaryfield.py
tests/model_fields/test_binaryfield.py
+6
-1
No files found.
docs/ref/models/fields.txt
Dosyayı görüntüle @
b3b47bf5
...
...
@@ -416,8 +416,8 @@ guaranteed to fit numbers from ``-9223372036854775808`` to
.. class:: BinaryField(max_length=None, **options)
A field to store raw binary data. It can be assigned :class:`bytes`
or a
:class:`memoryview`.
A field to store raw binary data. It can be assigned :class:`bytes`
,
:class:`
bytearray`, or :class:`
memoryview`.
By default, ``BinaryField`` sets :attr:`~Field.editable` to ``False``, in which
case it can't be included in a :class:`~django.forms.ModelForm`.
...
...
tests/model_fields/test_binaryfield.py
Dosyayı görüntüle @
b3b47bf5
...
...
@@ -9,7 +9,7 @@ class BinaryFieldTests(TestCase):
binary_data
=
b
'
\x00\x46\xFE
'
def
test_set_and_retrieve
(
self
):
data_set
=
(
self
.
binary_data
,
memoryview
(
self
.
binary_data
))
data_set
=
(
self
.
binary_data
,
bytearray
(
self
.
binary_data
),
memoryview
(
self
.
binary_data
))
for
bdata
in
data_set
:
dm
=
DataModel
(
data
=
bdata
)
dm
.
save
()
...
...
@@ -40,6 +40,11 @@ class BinaryFieldTests(TestCase):
DataModel
.
objects
.
create
(
data
=
b
'
\xef\xbb\xbf
'
)
self
.
assertSequenceEqual
(
DataModel
.
objects
.
filter
(
data
=
self
.
binary_data
),
[
dm
])
def
test_filter_bytearray
(
self
):
dm
=
DataModel
.
objects
.
create
(
data
=
self
.
binary_data
)
DataModel
.
objects
.
create
(
data
=
b
'
\xef\xbb\xbf
'
)
self
.
assertSequenceEqual
(
DataModel
.
objects
.
filter
(
data
=
bytearray
(
self
.
binary_data
)),
[
dm
])
def
test_filter_memoryview
(
self
):
dm
=
DataModel
.
objects
.
create
(
data
=
self
.
binary_data
)
DataModel
.
objects
.
create
(
data
=
b
'
\xef\xbb\xbf
'
)
...
...
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