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
491de4f0
Kaydet (Commit)
491de4f0
authored
Eyl 03, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #23656 -- Required FormMixin.get_form() form_class parameter to be optional.
Per deprecation timeline.
üst
849037af
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 addition
and
56 deletions
+1
-56
edit.py
django/views/generic/edit.py
+1
-27
mixins-editing.txt
docs/ref/class-based-views/mixins-editing.txt
+0
-4
test_edit.py
tests/generic_views/test_edit.py
+0
-25
No files found.
django/views/generic/edit.py
Dosyayı görüntüle @
491de4f0
import
inspect
import
warnings
from
django.core.exceptions
import
ImproperlyConfigured
from
django.forms
import
models
as
model_forms
from
django.http
import
HttpResponseRedirect
from
django.utils
import
six
from
django.utils.deprecation
import
RemovedInDjango110Warning
from
django.utils.encoding
import
force_text
from
django.views.generic.base
import
ContextMixin
,
TemplateResponseMixin
,
View
from
django.views.generic.detail
import
(
...
...
@@ -13,28 +8,7 @@ from django.views.generic.detail import (
)
class
FormMixinBase
(
type
):
def
__new__
(
cls
,
name
,
bases
,
attrs
):
get_form
=
attrs
.
get
(
'get_form'
)
if
get_form
and
inspect
.
isfunction
(
get_form
):
try
:
inspect
.
getcallargs
(
get_form
,
None
)
except
TypeError
:
warnings
.
warn
(
"`
%
s.
%
s.get_form` method must define a default value for "
"its `form_class` argument."
%
(
attrs
[
'__module__'
],
name
),
RemovedInDjango110Warning
,
stacklevel
=
2
)
def
get_form_with_form_class
(
self
,
form_class
=
None
):
if
form_class
is
None
:
form_class
=
self
.
get_form_class
()
return
get_form
(
self
,
form_class
=
form_class
)
attrs
[
'get_form'
]
=
get_form_with_form_class
return
super
(
FormMixinBase
,
cls
)
.
__new__
(
cls
,
name
,
bases
,
attrs
)
class
FormMixin
(
six
.
with_metaclass
(
FormMixinBase
,
ContextMixin
)):
class
FormMixin
(
ContextMixin
):
"""
A mixin that provides a way to show and handle a form in a request.
"""
...
...
docs/ref/class-based-views/mixins-editing.txt
Dosyayı görüntüle @
491de4f0
...
...
@@ -59,10 +59,6 @@ FormMixin
:meth:`~django.views.generic.edit.FormMixin.get_form_kwargs`.
If ``form_class`` isn't provided :meth:`get_form_class` will be used.
.. versionchanged:: 1.8
The ``form_class`` argument is not required anymore.
.. method:: get_form_kwargs()
Build the keyword arguments required to instantiate the form.
...
...
tests/generic_views/test_edit.py
Dosyayı görüntüle @
491de4f0
from
__future__
import
unicode_literals
import
warnings
from
django
import
forms
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.urlresolvers
import
reverse
from
django.test
import
SimpleTestCase
,
TestCase
,
override_settings
from
django.test.client
import
RequestFactory
from
django.utils.deprecation
import
RemovedInDjango110Warning
from
django.views.generic.base
import
View
from
django.views.generic.edit
import
CreateView
,
FormMixin
,
ModelFormMixin
...
...
@@ -59,28 +56,6 @@ class FormMixinTests(SimpleTestCase):
'get_form() should fallback to get_form_class() if none is provided.'
)
def
test_get_form_missing_form_class_default_value
(
self
):
with
warnings
.
catch_warnings
(
record
=
True
)
as
w
:
warnings
.
filterwarnings
(
'always'
)
class
MissingDefaultValue
(
FormMixin
):
request
=
RequestFactory
()
.
get
(
'/'
)
form_class
=
forms
.
Form
def
get_form
(
self
,
form_class
):
return
form_class
(
**
self
.
get_form_kwargs
())
self
.
assertEqual
(
len
(
w
),
1
)
self
.
assertEqual
(
w
[
0
]
.
category
,
RemovedInDjango110Warning
)
self
.
assertEqual
(
str
(
w
[
0
]
.
message
),
'`generic_views.test_edit.MissingDefaultValue.get_form` method '
'must define a default value for its `form_class` argument.'
)
self
.
assertIsInstance
(
MissingDefaultValue
()
.
get_form
(),
forms
.
Form
,
)
def
test_get_context_data
(
self
):
class
FormContext
(
FormMixin
):
request
=
RequestFactory
()
.
get
(
'/'
)
...
...
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