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
af7ea808
Kaydet (Commit)
af7ea808
authored
Kas 01, 2012
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added WizardView.file_storage exception message and docs
Thanks Danilo Bargen for the patch.
üst
d9213d09
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
7 deletions
+40
-7
base.py
django/contrib/formtools/wizard/storage/base.py
+6
-2
views.py
django/contrib/formtools/wizard/views.py
+7
-5
form-wizard.txt
docs/ref/contrib/formtools/form-wizard.txt
+25
-0
files.txt
docs/topics/files.txt
+2
-0
No files found.
django/contrib/formtools/wizard/storage/base.py
Dosyayı görüntüle @
af7ea808
...
@@ -69,7 +69,9 @@ class BaseStorage(object):
...
@@ -69,7 +69,9 @@ class BaseStorage(object):
wizard_files
=
self
.
data
[
self
.
step_files_key
]
.
get
(
step
,
{})
wizard_files
=
self
.
data
[
self
.
step_files_key
]
.
get
(
step
,
{})
if
wizard_files
and
not
self
.
file_storage
:
if
wizard_files
and
not
self
.
file_storage
:
raise
NoFileStorageConfigured
raise
NoFileStorageConfigured
(
"You need to define 'file_storage' in your "
"wizard view in order to handle file uploads."
)
files
=
{}
files
=
{}
for
field
,
field_dict
in
six
.
iteritems
(
wizard_files
):
for
field
,
field_dict
in
six
.
iteritems
(
wizard_files
):
...
@@ -81,7 +83,9 @@ class BaseStorage(object):
...
@@ -81,7 +83,9 @@ class BaseStorage(object):
def
set_step_files
(
self
,
step
,
files
):
def
set_step_files
(
self
,
step
,
files
):
if
files
and
not
self
.
file_storage
:
if
files
and
not
self
.
file_storage
:
raise
NoFileStorageConfigured
raise
NoFileStorageConfigured
(
"You need to define 'file_storage' in your "
"wizard view in order to handle file uploads."
)
if
step
not
in
self
.
data
[
self
.
step_files_key
]:
if
step
not
in
self
.
data
[
self
.
step_files_key
]:
self
.
data
[
self
.
step_files_key
][
step
]
=
{}
self
.
data
[
self
.
step_files_key
][
step
]
=
{}
...
...
django/contrib/formtools/wizard/views.py
Dosyayı görüntüle @
af7ea808
...
@@ -174,7 +174,9 @@ class WizardView(TemplateView):
...
@@ -174,7 +174,9 @@ class WizardView(TemplateView):
for
field
in
six
.
itervalues
(
form
.
base_fields
):
for
field
in
six
.
itervalues
(
form
.
base_fields
):
if
(
isinstance
(
field
,
forms
.
FileField
)
and
if
(
isinstance
(
field
,
forms
.
FileField
)
and
not
hasattr
(
cls
,
'file_storage'
)):
not
hasattr
(
cls
,
'file_storage'
)):
raise
NoFileStorageConfigured
raise
NoFileStorageConfigured
(
"You need to define 'file_storage' in your "
"wizard view in order to handle file uploads."
)
# build the kwargs for the wizardview instances
# build the kwargs for the wizardview instances
kwargs
[
'form_list'
]
=
init_form_list
kwargs
[
'form_list'
]
=
init_form_list
...
@@ -436,8 +438,8 @@ class WizardView(TemplateView):
...
@@ -436,8 +438,8 @@ class WizardView(TemplateView):
def
get_all_cleaned_data
(
self
):
def
get_all_cleaned_data
(
self
):
"""
"""
Returns a merged dictionary of all step cleaned_data dictionaries.
Returns a merged dictionary of all step cleaned_data dictionaries.
If a step contains a `FormSet`, the key will be prefixed with
formset
If a step contains a `FormSet`, the key will be prefixed with
and contain a list of the formset cleaned_data dictionaries.
'formset-'
and contain a list of the formset cleaned_data dictionaries.
"""
"""
cleaned_data
=
{}
cleaned_data
=
{}
for
form_key
in
self
.
get_form_list
():
for
form_key
in
self
.
get_form_list
():
...
@@ -458,8 +460,8 @@ class WizardView(TemplateView):
...
@@ -458,8 +460,8 @@ class WizardView(TemplateView):
def
get_cleaned_data_for_step
(
self
,
step
):
def
get_cleaned_data_for_step
(
self
,
step
):
"""
"""
Returns the cleaned data for a given `step`. Before returning the
Returns the cleaned data for a given `step`. Before returning the
cleaned data, the stored values are
being revalidated through the
cleaned data, the stored values are
revalidated through the form.
form.
If the data doesn't validate, None will be returned.
If the data doesn't validate, None will be returned.
"""
"""
if
step
in
self
.
form_list
:
if
step
in
self
.
form_list
:
form_obj
=
self
.
get_form
(
step
=
step
,
form_obj
=
self
.
get_form
(
step
=
step
,
...
...
docs/ref/contrib/formtools/form-wizard.txt
Dosyayı görüntüle @
af7ea808
...
@@ -493,6 +493,21 @@ Advanced ``WizardView`` methods
...
@@ -493,6 +493,21 @@ Advanced ``WizardView`` methods
context = self.get_context_data(form=form, **kwargs)
context = self.get_context_data(form=form, **kwargs)
return self.render_to_response(context)
return self.render_to_response(context)
.. method:: WizardView.get_cleaned_data_for_step(step)
This method returns the cleaned data for a given ``step``. Before returning
the cleaned data, the stored values are revalidated through the form. If
the data doesn't validate, ``None`` will be returned.
.. method:: WizardView.get_all_cleaned_data()
This method returns a merged dictionary of all form steps' ``cleaned_data``
dictionaries. If a step contains a ``FormSet``, the key will be prefixed
with ``formset-`` and contain a list of the formset's ``cleaned_data``
dictionaries. Note that if two or more steps have a field with the same
name, the value for that field from the latest step will overwrite the
value from any earlier steps.
Providing initial data for the forms
Providing initial data for the forms
====================================
====================================
...
@@ -534,6 +549,16 @@ This storage will temporarily store the uploaded files for the wizard. The
...
@@ -534,6 +549,16 @@ This storage will temporarily store the uploaded files for the wizard. The
:attr:`file_storage` attribute should be a
:attr:`file_storage` attribute should be a
:class:`~django.core.files.storage.Storage` subclass.
:class:`~django.core.files.storage.Storage` subclass.
Django provides a built-in storage class (see :ref:`the built-in filesystem
storage class <builtin-fs-storage>`)::
from django.conf import settings
from django.core.files.storage import FileSystemStorage
class CustomWizardView(WizardView):
...
file_storage = FileSystemStorage(location=os.path.join(settings.MEDIA_ROOT, 'photos'))
.. warning::
.. warning::
Please remember to take care of removing old files as the
Please remember to take care of removing old files as the
...
...
docs/topics/files.txt
Dosyayı görüntüle @
af7ea808
...
@@ -139,6 +139,8 @@ useful -- you can use the global default storage system::
...
@@ -139,6 +139,8 @@ useful -- you can use the global default storage system::
See :doc:`/ref/files/storage` for the file storage API.
See :doc:`/ref/files/storage` for the file storage API.
.. _builtin-fs-storage:
The built-in filesystem storage class
The built-in filesystem storage class
-------------------------------------
-------------------------------------
...
...
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