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
0083a4c8
Kaydet (Commit)
0083a4c8
authored
Eki 04, 2016
tarafından
Tim Graham
Kaydeden (comit)
GitHub
Eki 04, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #18974 -- Deprecated @models.permalink() decorator.
üst
aa9569fc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
14 deletions
+55
-14
__init__.py
django/db/models/__init__.py
+10
-2
deprecation.txt
docs/internals/deprecation.txt
+2
-0
1.11.txt
docs/releases/1.11.txt
+25
-0
models.py
tests/model_permalink/models.py
+18
-12
No files found.
django/db/models/__init__.py
Dosyayı görüntüle @
0083a4c8
from
functools
import
wraps
from
django.core.exceptions
import
ObjectDoesNotExist
# NOQA
from
django.db.models
import
signals
# NOQA
from
django.db.models.aggregates
import
*
# NOQA
...
...
@@ -37,7 +35,17 @@ def permalink(func):
(viewname, viewargs)
(viewname, viewargs, viewkwargs)
"""
import
warnings
from
functools
import
wraps
from
django.urls
import
reverse
from
django.utils.deprecation
import
RemovedInDjango21Warning
warnings
.
warn
(
'permalink() is deprecated in favor of calling django.urls.reverse() '
'in the decorated method.'
,
RemovedInDjango21Warning
)
@wraps
(
func
)
def
inner
(
*
args
,
**
kwargs
):
...
...
docs/internals/deprecation.txt
Dosyayı görüntüle @
0083a4c8
...
...
@@ -41,6 +41,8 @@ details on these changes.
* The ``authenticate()`` method of authentication backends will require a
``request`` argument.
* The ``django.db.models.permalink()`` decorator will be removed.
.. _deprecation-removed-in-2.0:
2.0
...
...
docs/releases/1.11.txt
Dosyayı görüntüle @
0083a4c8
...
...
@@ -554,6 +554,31 @@ Miscellaneous
Features deprecated in 1.11
===========================
``models.permalink()`` decorator
--------------------------------
Use :func:`django.urls.reverse` instead. For example::
from django.db import models
class MyModel(models.Model):
...
@models.permalink
def url(self):
return ('guitarist_detail', [self.slug])
becomes::
from django.db import models
from django.urls import reverse
class MyModel(models.Model):
...
def url(self):
return reverse('guitarist_detail', args=[self.slug])
Miscellaneous
-------------
...
...
tests/model_permalink/models.py
Dosyayı görüntüle @
0083a4c8
import
warnings
from
django.db
import
models
from
django.utils.deprecation
import
RemovedInDjango21Warning
def
set_attr
(
name
,
value
):
...
...
@@ -8,17 +11,20 @@ def set_attr(name, value):
return
wrapper
class
Guitarist
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
slug
=
models
.
CharField
(
max_length
=
50
)
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'ignore'
,
category
=
RemovedInDjango21Warning
)
class
Guitarist
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
slug
=
models
.
CharField
(
max_length
=
50
)
@models.permalink
def
url
(
self
):
"Returns the URL for this guitarist."
return
(
'guitarist_detail'
,
[
self
.
slug
])
@models.permalink
def
url
(
self
):
"Returns the URL for this guitarist."
return
(
'guitarist_detail'
,
[
self
.
slug
])
@models.permalink
@set_attr
(
'attribute'
,
'value'
)
def
url_with_attribute
(
self
):
"Returns the URL for this guitarist and holds an attribute"
return
(
'guitarist_detail'
,
[
self
.
slug
])
@models.permalink
@set_attr
(
'attribute'
,
'value'
)
def
url_with_attribute
(
self
):
"Returns the URL for this guitarist and holds an attribute"
return
(
'guitarist_detail'
,
[
self
.
slug
])
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