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
7d607127
Kaydet (Commit)
7d607127
authored
Ock 21, 2018
tarafından
Jon Dufresne
Kaydeden (comit)
Tim Graham
Ock 23, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refs #21221 -- Deprecated staticfiles and admin_static template tag libraries.
üst
f0f383b6
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
109 additions
and
23 deletions
+109
-23
admin_static.py
django/contrib/admin/templatetags/admin_static.py
+7
-2
staticfiles.py
django/contrib/staticfiles/templatetags/staticfiles.py
+13
-4
deprecation.txt
docs/internals/deprecation.txt
+5
-0
2.1.txt
docs/releases/2.1.txt
+6
-0
test_static_deprecation.py
tests/admin_views/test_static_deprecation.py
+30
-0
tests.py
tests/admin_views/tests.py
+0
-14
cases.py
tests/staticfiles_tests/cases.py
+2
-2
test_forms.py
tests/staticfiles_tests/test_forms.py
+1
-1
test_templatetag_deprecation.py
tests/staticfiles_tests/test_templatetag_deprecation.py
+45
-0
No files found.
django/contrib/admin/templatetags/admin_static.py
Dosyayı görüntüle @
7d607127
import
warnings
from
django.template
import
Library
from
django.templatetags.static
import
static
as
_static
from
django.utils.deprecation
import
RemovedInDjango30Warning
register
=
Library
()
@register.simple_tag
def
static
(
path
):
# Backwards compatibility alias for django.templatetags.static.static().
# Deprecation should start in Django 2.0.
warnings
.
warn
(
'{
%
load admin_static
%
} is deprecated in favor of {
%
load static
%
}.'
,
RemovedInDjango30Warning
,
)
return
_static
(
path
)
django/contrib/staticfiles/templatetags/staticfiles.py
Dosyayı görüntüle @
7d607127
import
warnings
from
django
import
template
from
django.templatetags.static
import
(
do_static
as
_do_static
,
static
as
_static
,
)
from
django.utils.deprecation
import
RemovedInDjango30Warning
register
=
template
.
Library
()
def
static
(
path
):
# Backwards compatibility alias for django.templatetags.static.static().
# Deprecation should start in Django 2.0.
warnings
.
warn
(
'django.contrib.staticfiles.templatetags.static() is deprecated in '
'favor of django.templatetags.static.static().'
,
RemovedInDjango30Warning
,
stacklevel
=
2
,
)
return
_static
(
path
)
@register.tag
(
'static'
)
def
do_static
(
parser
,
token
):
# Backwards compatibility alias for django.templatetags.static.do_static().
# Deprecation should start in Django 2.0.
warnings
.
warn
(
'{
%
load staticfiles
%
} is deprecated in favor of {
%
load static
%
}.'
,
RemovedInDjango30Warning
,
)
return
_do_static
(
parser
,
token
)
docs/internals/deprecation.txt
Dosyayı görüntüle @
7d607127
...
...
@@ -33,6 +33,11 @@ details on these changes.
* ``django.utils.http.cookie_date()`` will be removed.
* The ``staticfiles`` and ``admin_static`` template tag libraries will be
removed.
* ``django.contrib.staticfiles.templatetags.static()`` will be removed.
See the :ref:`Django 2.1 release notes <deprecated-features-2.1>` for more
details on these changes.
...
...
docs/releases/2.1.txt
Dosyayı görüntüle @
7d607127
...
...
@@ -274,6 +274,12 @@ Miscellaneous
:func:`~django.utils.http.http_date`, which follows the format of the latest
RFC.
* ``{% load staticfiles %}`` and ``{% load admin_static %}`` are deprecated
in favor of ``{% load static %}``, which works the same.
* ``django.contrib.staticfiles.templatetags.static()`` is deprecated in favor
of ``django.templatetags.static.static()``.
.. _removed-features-2.1:
Features removed in 2.1
...
...
tests/admin_views/test_static_deprecation.py
0 → 100644
Dosyayı görüntüle @
7d607127
import
warnings
from
django.contrib.admin.templatetags.admin_static
import
static
from
django.contrib.staticfiles.storage
import
staticfiles_storage
from
django.test
import
SimpleTestCase
from
django.utils.deprecation
import
RemovedInDjango30Warning
class
AdminStaticDeprecationTests
(
SimpleTestCase
):
def
test
(
self
):
"""
admin_static.static points to the collectstatic version
(as django.contrib.collectstatic is in INSTALLED_APPS).
"""
msg
=
(
'{
%
load admin_static
%
} is deprecated in favor of '
'{
%
load static
%
}.'
)
old_url
=
staticfiles_storage
.
base_url
staticfiles_storage
.
base_url
=
'/test/'
try
:
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
warnings
.
simplefilter
(
'always'
)
url
=
static
(
'path'
)
self
.
assertEqual
(
url
,
'/test/path'
)
self
.
assertEqual
(
len
(
recorded
),
1
)
self
.
assertIs
(
recorded
[
0
]
.
category
,
RemovedInDjango30Warning
)
self
.
assertEqual
(
str
(
recorded
[
0
]
.
message
),
msg
)
finally
:
staticfiles_storage
.
base_url
=
old_url
tests/admin_views/tests.py
Dosyayı görüntüle @
7d607127
...
...
@@ -10,7 +10,6 @@ from django.contrib.admin import AdminSite, ModelAdmin
from
django.contrib.admin.helpers
import
ACTION_CHECKBOX_NAME
from
django.contrib.admin.models
import
ADDITION
,
DELETION
,
LogEntry
from
django.contrib.admin.options
import
TO_FIELD_VAR
from
django.contrib.admin.templatetags.admin_static
import
static
from
django.contrib.admin.templatetags.admin_urls
import
add_preserved_filters
from
django.contrib.admin.tests
import
AdminSeleniumTestCase
from
django.contrib.admin.utils
import
quote
...
...
@@ -18,7 +17,6 @@ from django.contrib.admin.views.main import IS_POPUP_VAR
from
django.contrib.auth
import
REDIRECT_FIELD_NAME
,
get_permission_codename
from
django.contrib.auth.models
import
Group
,
Permission
,
User
from
django.contrib.contenttypes.models
import
ContentType
from
django.contrib.staticfiles.storage
import
staticfiles_storage
from
django.core
import
mail
from
django.core.checks
import
Error
from
django.core.files
import
temp
as
tempfile
...
...
@@ -200,18 +198,6 @@ class AdminViewBasicTest(AdminViewBasicTestCase):
response
=
self
.
client
.
get
(
add_url
[:
-
1
])
self
.
assertRedirects
(
response
,
add_url
,
status_code
=
301
)
def
test_admin_static_template_tag
(
self
):
"""
admin_static.static points to the collectstatic version
(as django.contrib.collectstatic is in INSTALLED_APPS).
"""
old_url
=
staticfiles_storage
.
base_url
staticfiles_storage
.
base_url
=
'/test/'
try
:
self
.
assertEqual
(
static
(
'path'
),
'/test/path'
)
finally
:
staticfiles_storage
.
base_url
=
old_url
def
test_basic_add_GET
(
self
):
"""
A smoke test to ensure GET on the add_view works.
...
...
tests/staticfiles_tests/cases.py
Dosyayı görüntüle @
7d607127
...
...
@@ -34,8 +34,8 @@ class BaseStaticFilesMixin:
def
static_template_snippet
(
self
,
path
,
asvar
=
False
):
if
asvar
:
return
"{
%%
load static from static
files
%%
}{
%%
static '
%
s' as var
%%
}{{ var }}"
%
path
return
"{
%%
load static from static
files
%%
}{
%%
static '
%
s'
%%
}"
%
path
return
"{
%%
load static from static
%%
}{
%%
static '
%
s' as var
%%
}{{ var }}"
%
path
return
"{
%%
load static from static
%%
}{
%%
static '
%
s'
%%
}"
%
path
def
assertStaticRenders
(
self
,
path
,
result
,
asvar
=
False
,
**
kwargs
):
template
=
self
.
static_template_snippet
(
path
,
asvar
)
...
...
tests/staticfiles_tests/test_forms.py
Dosyayı görüntüle @
7d607127
from
urllib.parse
import
urljoin
from
django.contrib.staticfiles
import
storage
from
django.contrib.staticfiles.templatetags.staticfiles
import
static
from
django.forms
import
Media
from
django.templatetags.static
import
static
from
django.test
import
SimpleTestCase
,
override_settings
...
...
tests/staticfiles_tests/test_templatetag_deprecation.py
0 → 100644
Dosyayı görüntüle @
7d607127
import
warnings
from
urllib.parse
import
urljoin
from
django.contrib.staticfiles
import
storage
from
django.contrib.staticfiles.templatetags.staticfiles
import
static
from
django.template
import
Context
,
Template
from
django.test
import
SimpleTestCase
,
override_settings
from
django.utils.deprecation
import
RemovedInDjango30Warning
class
StaticTestStorage
(
storage
.
StaticFilesStorage
):
def
url
(
self
,
name
):
return
urljoin
(
'https://example.com/assets/'
,
name
)
@override_settings
(
STATIC_URL
=
'http://media.example.com/static/'
,
INSTALLED_APPS
=
(
'django.contrib.staticfiles'
,),
STATICFILES_STORAGE
=
'staticfiles_tests.test_forms.StaticTestStorage'
,
)
class
StaticDeprecationTests
(
SimpleTestCase
):
def
test_templatetag_deprecated
(
self
):
msg
=
'{
%
load staticfiles
%
} is deprecated in favor of {
%
load static
%
}.'
template
=
"{
%
load staticfiles
%
}{
%
static 'main.js'
%
}"
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
warnings
.
simplefilter
(
'always'
)
template
=
Template
(
template
)
rendered
=
template
.
render
(
Context
())
self
.
assertEqual
(
rendered
,
'https://example.com/assets/main.js'
)
self
.
assertEqual
(
len
(
recorded
),
1
)
self
.
assertIs
(
recorded
[
0
]
.
category
,
RemovedInDjango30Warning
)
self
.
assertEqual
(
str
(
recorded
[
0
]
.
message
),
msg
)
def
test_static_deprecated
(
self
):
msg
=
(
'django.contrib.staticfiles.templatetags.static() is deprecated in '
'favor of django.templatetags.static.static().'
)
with
warnings
.
catch_warnings
(
record
=
True
)
as
recorded
:
warnings
.
simplefilter
(
'always'
)
url
=
static
(
'main.js'
)
self
.
assertEqual
(
url
,
'https://example.com/assets/main.js'
)
self
.
assertEqual
(
len
(
recorded
),
1
)
self
.
assertIs
(
recorded
[
0
]
.
category
,
RemovedInDjango30Warning
)
self
.
assertEqual
(
str
(
recorded
[
0
]
.
message
),
msg
)
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