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
c70ca487
Kaydet (Commit)
c70ca487
authored
May 19, 2013
tarafından
Marc Tamlyn
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #1116 from elektrrrus/ticket_20234_20236
Ticket 20234 20236
üst
0a503110
3eba8c7f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
19 deletions
+23
-19
detail.py
django/views/generic/detail.py
+6
-4
edit.py
django/views/generic/edit.py
+0
-14
test_base.py
tests/generic_views/test_base.py
+13
-0
views.py
tests/generic_views/views.py
+4
-1
No files found.
django/views/generic/detail.py
Dosyayı görüntüle @
c70ca487
...
...
@@ -93,9 +93,11 @@ class SingleObjectMixin(ContextMixin):
Insert the single object into the context dict.
"""
context
=
{}
context_object_name
=
self
.
get_context_object_name
(
self
.
object
)
if
context_object_name
:
context
[
context_object_name
]
=
self
.
object
if
self
.
object
:
context
[
'object'
]
=
self
.
object
context_object_name
=
self
.
get_context_object_name
(
self
.
object
)
if
context_object_name
:
context
[
context_object_name
]
=
self
.
object
context
.
update
(
kwargs
)
return
super
(
SingleObjectMixin
,
self
)
.
get_context_data
(
**
context
)
...
...
@@ -122,7 +124,7 @@ class SingleObjectTemplateResponseMixin(TemplateResponseMixin):
* the value of ``template_name`` on the view (if provided)
* the contents of the ``template_name_field`` field on the
object instance that the view is operating upon (if available)
* ``<app_label>/<object_name><template_name_suffix>.html``
* ``<app_label>/<object_name><template_name_suffix>.html``
"""
try
:
names
=
super
(
SingleObjectTemplateResponseMixin
,
self
)
.
get_template_names
()
...
...
django/views/generic/edit.py
Dosyayı görüntüle @
c70ca487
...
...
@@ -136,20 +136,6 @@ class ModelFormMixin(FormMixin, SingleObjectMixin):
self
.
object
=
form
.
save
()
return
super
(
ModelFormMixin
,
self
)
.
form_valid
(
form
)
def
get_context_data
(
self
,
**
kwargs
):
"""
If an object has been supplied, inject it into the context with the
supplied context_object_name name.
"""
context
=
{}
if
self
.
object
:
context
[
'object'
]
=
self
.
object
context_object_name
=
self
.
get_context_object_name
(
self
.
object
)
if
context_object_name
:
context
[
context_object_name
]
=
self
.
object
context
.
update
(
kwargs
)
return
super
(
ModelFormMixin
,
self
)
.
get_context_data
(
**
context
)
class
ProcessFormView
(
View
):
"""
...
...
tests/generic_views/test_base.py
Dosyayı görüntüle @
c70ca487
...
...
@@ -412,6 +412,19 @@ class GetContextDataTest(unittest.TestCase):
context
=
test_view
.
get_context_data
(
test_name
=
'test_value'
)
self
.
assertEqual
(
context
[
'test_name'
],
'test_value'
)
def
test_object_at_custom_name_in_context_data
(
self
):
# Checks 'pony' key presence in dict returned by get_context_date
test_view
=
views
.
CustomSingleObjectView
()
test_view
.
context_object_name
=
'pony'
context
=
test_view
.
get_context_data
()
self
.
assertEqual
(
context
[
'pony'
],
test_view
.
object
)
def
test_object_in_get_context_data
(
self
):
# Checks 'object' key presence in dict returned by get_context_date #20234
test_view
=
views
.
CustomSingleObjectView
()
context
=
test_view
.
get_context_data
()
self
.
assertEqual
(
context
[
'object'
],
test_view
.
object
)
class
UseMultipleObjectMixinTest
(
unittest
.
TestCase
):
rf
=
RequestFactory
()
...
...
tests/generic_views/views.py
Dosyayı görüntüle @
c70ca487
from
__future__
import
absolute_import
from
django.contrib.auth.decorators
import
login_required
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.core.paginator
import
Paginator
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.utils.decorators
import
method_decorator
...
...
@@ -227,6 +226,10 @@ class CustomContextView(generic.detail.SingleObjectMixin, generic.View):
def
get_context_object_name
(
self
,
obj
):
return
"test_name"
class
CustomSingleObjectView
(
generic
.
detail
.
SingleObjectMixin
,
generic
.
View
):
model
=
Book
object
=
Book
(
name
=
"dummy"
)
class
BookSigningConfig
(
object
):
model
=
BookSigning
date_field
=
'event_date'
...
...
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