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
6eed9ae7
Kaydet (Commit)
6eed9ae7
authored
Eyl 02, 2015
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #24133 -- Removed legacy formatting syntax in success_url placeholders.
Per deprecation timeline.
üst
b6e6fcf3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
46 deletions
+6
-46
edit.py
django/views/generic/edit.py
+2
-25
mixins-editing.txt
docs/ref/class-based-views/mixins-editing.txt
+0
-12
test_edit.py
tests/generic_views/test_edit.py
+1
-6
urls.py
tests/generic_views/urls.py
+3
-3
No files found.
django/views/generic/edit.py
Dosyayı görüntüle @
6eed9ae7
import
inspect
import
re
import
warnings
from
django.core.exceptions
import
ImproperlyConfigured
...
...
@@ -13,8 +12,6 @@ from django.views.generic.detail import (
BaseDetailView
,
SingleObjectMixin
,
SingleObjectTemplateResponseMixin
,
)
PERCENT_PLACEHOLDER_REGEX
=
re
.
compile
(
r'
%
\([^\)]+\)'
)
# RemovedInDjango110Warning
class
FormMixinBase
(
type
):
def
__new__
(
cls
,
name
,
bases
,
attrs
):
...
...
@@ -173,17 +170,7 @@ class ModelFormMixin(FormMixin, SingleObjectMixin):
Returns the supplied URL.
"""
if
self
.
success_url
:
# force_text can be removed with deprecation warning
self
.
success_url
=
force_text
(
self
.
success_url
)
if
PERCENT_PLACEHOLDER_REGEX
.
search
(
self
.
success_url
):
warnings
.
warn
(
"
%
()s placeholder style in success_url is deprecated. "
"Please replace them by the {} Python format syntax."
,
RemovedInDjango110Warning
,
stacklevel
=
2
)
url
=
self
.
success_url
%
self
.
object
.
__dict__
else
:
url
=
self
.
success_url
.
format
(
**
self
.
object
.
__dict__
)
url
=
self
.
success_url
.
format
(
**
self
.
object
.
__dict__
)
else
:
try
:
url
=
self
.
object
.
get_absolute_url
()
...
...
@@ -308,17 +295,7 @@ class DeletionMixin(object):
def
get_success_url
(
self
):
if
self
.
success_url
:
# force_text can be removed with deprecation warning
self
.
success_url
=
force_text
(
self
.
success_url
)
if
PERCENT_PLACEHOLDER_REGEX
.
search
(
self
.
success_url
):
warnings
.
warn
(
"
%
()s placeholder style in success_url is deprecated. "
"Please replace them by the {} Python format syntax."
,
RemovedInDjango110Warning
,
stacklevel
=
2
)
return
self
.
success_url
%
self
.
object
.
__dict__
else
:
return
self
.
success_url
.
format
(
**
self
.
object
.
__dict__
)
return
self
.
success_url
.
format
(
**
self
.
object
.
__dict__
)
else
:
raise
ImproperlyConfigured
(
"No URL to redirect to. Provide a success_url."
)
...
...
docs/ref/class-based-views/mixins-editing.txt
Dosyayı görüntüle @
6eed9ae7
...
...
@@ -160,12 +160,6 @@ ModelFormMixin
example, you could use ``success_url="/polls/{slug}/"`` to
redirect to a URL composed out of the ``slug`` field on a model.
.. versionchanged:: 1.8
Support for the new brace-based Python formatting syntax has been
added. The old ``%(slug)s`` placeholder syntax support has been
deprecated and will be removed in Django 1.10.
.. method:: get_form_class()
Retrieve the form class to instantiate. If
...
...
@@ -259,12 +253,6 @@ DeletionMixin
could use ``success_url="/parent/{parent_id}/"`` to redirect to a URL
composed out of the ``parent_id`` field on a model.
.. versionchanged:: 1.8
Support for the new brace-based Python formatting syntax has been
added. The old ``%(slug)s`` placeholder syntax support has been
deprecated and will be removed in Django 1.10.
.. method:: get_success_url()
Returns the url to redirect to when the nominated object has been
...
...
tests/generic_views/test_edit.py
Dosyayı görüntüle @
6eed9ae7
...
...
@@ -5,9 +5,7 @@ import warnings
from
django
import
forms
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.urlresolvers
import
reverse
from
django.test
import
(
SimpleTestCase
,
TestCase
,
ignore_warnings
,
override_settings
,
)
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
...
...
@@ -152,7 +150,6 @@ class CreateViewTests(TestCase):
self
.
assertRedirects
(
res
,
'/edit/authors/create/'
)
self
.
assertQuerysetEqual
(
Author
.
objects
.
all
(),
[
'<Author: Randall Munroe>'
])
@ignore_warnings
(
category
=
RemovedInDjango110Warning
)
def
test_create_with_interpolated_redirect
(
self
):
res
=
self
.
client
.
post
(
'/edit/authors/create/interpolate_redirect/'
,
...
...
@@ -292,7 +289,6 @@ class UpdateViewTests(TestCase):
self
.
assertRedirects
(
res
,
'/edit/authors/create/'
)
self
.
assertQuerysetEqual
(
Author
.
objects
.
all
(),
[
'<Author: Randall Munroe (author of xkcd)>'
])
@ignore_warnings
(
category
=
RemovedInDjango110Warning
)
def
test_update_with_interpolated_redirect
(
self
):
a
=
Author
.
objects
.
create
(
name
=
'Randall Munroe'
,
...
...
@@ -399,7 +395,6 @@ class DeleteViewTests(TestCase):
self
.
assertRedirects
(
res
,
'/edit/authors/create/'
)
self
.
assertQuerysetEqual
(
Author
.
objects
.
all
(),
[])
@ignore_warnings
(
category
=
RemovedInDjango110Warning
)
def
test_delete_with_interpolated_redirect
(
self
):
a
=
Author
.
objects
.
create
(
**
{
'name'
:
'Randall Munroe'
,
'slug'
:
'randall-munroe'
})
res
=
self
.
client
.
post
(
'/edit/author/
%
d/delete/interpolate_redirect/'
%
a
.
pk
)
...
...
tests/generic_views/urls.py
Dosyayı görüntüle @
6eed9ae7
...
...
@@ -77,7 +77,7 @@ urlpatterns = [
url
(
r'^edit/authors/create/redirect/$'
,
views
.
NaiveAuthorCreate
.
as_view
(
success_url
=
'/edit/authors/create/'
)),
url
(
r'^edit/authors/create/interpolate_redirect/$'
,
views
.
NaiveAuthorCreate
.
as_view
(
success_url
=
'/edit/author/
%(id)
d
/update/'
)),
views
.
NaiveAuthorCreate
.
as_view
(
success_url
=
'/edit/author/
{id}
/update/'
)),
url
(
r'^edit/authors/create/interpolate_redirect_nonascii/$'
,
views
.
NaiveAuthorCreate
.
as_view
(
success_url
=
'/
%
C3
%
A9dit/author/{id}/update/'
)),
url
(
r'^edit/authors/create/restricted/$'
,
...
...
@@ -92,7 +92,7 @@ urlpatterns = [
url
(
r'^edit/author/(?P<pk>[0-9]+)/update/redirect/$'
,
views
.
NaiveAuthorUpdate
.
as_view
(
success_url
=
'/edit/authors/create/'
)),
url
(
r'^edit/author/(?P<pk>[0-9]+)/update/interpolate_redirect/$'
,
views
.
NaiveAuthorUpdate
.
as_view
(
success_url
=
'/edit/author/
%(id)
d
/update/'
)),
views
.
NaiveAuthorUpdate
.
as_view
(
success_url
=
'/edit/author/
{id}
/update/'
)),
url
(
r'^edit/author/(?P<pk>[0-9]+)/update/interpolate_redirect_nonascii/$'
,
views
.
NaiveAuthorUpdate
.
as_view
(
success_url
=
'/
%
C3
%
A9dit/author/{id}/update/'
)),
url
(
r'^[eé]dit/author/(?P<pk>[0-9]+)/update/$'
,
...
...
@@ -106,7 +106,7 @@ urlpatterns = [
url
(
r'^edit/author/(?P<pk>[0-9]+)/delete/redirect/$'
,
views
.
NaiveAuthorDelete
.
as_view
(
success_url
=
'/edit/authors/create/'
)),
url
(
r'^edit/author/(?P<pk>[0-9]+)/delete/interpolate_redirect/$'
,
views
.
NaiveAuthorDelete
.
as_view
(
success_url
=
'/edit/authors/create/?deleted=
%(id)
s
'
)),
views
.
NaiveAuthorDelete
.
as_view
(
success_url
=
'/edit/authors/create/?deleted=
{id}
'
)),
url
(
r'^edit/author/(?P<pk>[0-9]+)/delete/interpolate_redirect_nonascii/$'
,
views
.
NaiveAuthorDelete
.
as_view
(
success_url
=
'/
%
C3
%
A9dit/authors/create/?deleted={id}'
)),
url
(
r'^edit/author/(?P<pk>[0-9]+)/delete/$'
,
...
...
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