kopia lustrzana https://github.com/wagtail/wagtail
Removed all uses of STATIC_URL from code samples, replaced with static().
Concatinating with settings.STATIC_URL is no longer reccomended for creating URLs to static resources, because it doesn't take the configured storage engine into account. For example, a site using S3 to store its static files will need static URLs that link out to S3, rather than relative URLs within the same domain. I replaced it with django.contrib.staticfiles.templatetags.staticfiles.static() in python example code, and the {% static %} tag in template examples.pull/2532/merge
rodzic
11793f88c5
commit
7523d7f57f
|
@ -39,9 +39,10 @@ The template blocks that are available to be overridden are as follows:
|
|||
To replace the default logo, create a template file ``dashboard/templates/wagtailadmin/base.html`` that overrides the block ``branding_logo``::
|
||||
|
||||
{% overextends "wagtailadmin/base.html" %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block branding_logo %}
|
||||
<img src="{{ STATIC_URL }}images/custom-logo.svg" alt="Custom Project" width="80" />
|
||||
<img src="{% static 'images/custom-logo.svg' %}" alt="Custom Project" width="80" />
|
||||
{% endblock %}
|
||||
|
||||
``branding_favicon``
|
||||
|
@ -50,9 +51,10 @@ To replace the default logo, create a template file ``dashboard/templates/wagtai
|
|||
To replace the favicon displayed when viewing admin pages, create a template file ``dashboard/templates/wagtailadmin/admin_base.html`` that overrides the block ``branding_favicon``::
|
||||
|
||||
{% overextends "wagtailadmin/admin_base.html" %}
|
||||
{% load staticfiles %}
|
||||
|
||||
{% block branding_favicon %}
|
||||
<link rel="shortcut icon" href="{{ STATIC_URL }}images/favicon.ico" />
|
||||
<link rel="shortcut icon" href="{% static 'images/favicon.ico' %}" />
|
||||
{% endblock %}
|
||||
|
||||
``branding_login``
|
||||
|
|
|
@ -257,16 +257,17 @@ Hooks for customising the editing interface for pages and snippets.
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
from django.contrib.staticfiles.templatetags.staticfiles import static
|
||||
from django.utils.html import format_html
|
||||
from django.conf import settings
|
||||
|
||||
from wagtail.wagtailcore import hooks
|
||||
|
||||
@hooks.register('insert_editor_css')
|
||||
def editor_css():
|
||||
return format_html('<link rel="stylesheet" href="' \
|
||||
+ settings.STATIC_URL \
|
||||
+ 'demo/css/vendor/font-awesome/css/font-awesome.min.css">')
|
||||
return format_html(
|
||||
'<link rel="stylesheet" href="{}">',
|
||||
static('demo/css/vendor/font-awesome/css/font-awesome.min.css')
|
||||
)
|
||||
|
||||
|
||||
.. _insert_global_admin_css:
|
||||
|
@ -274,20 +275,18 @@ Hooks for customising the editing interface for pages and snippets.
|
|||
``insert_global_admin_css``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Add additional CSS files or snippets to all admin pages.
|
||||
Add additional CSS files or snippets to all admin pages.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from django.utils.html import format_html
|
||||
from django.conf import settings
|
||||
|
||||
from wagtail.wagtailcore import hooks
|
||||
|
||||
@hooks.register('insert_global_admin_css')
|
||||
def global_admin_css():
|
||||
return format_html('<link rel="stylesheet" href="' \
|
||||
+ settings.STATIC_URL \
|
||||
+ 'my/wagtail/theme.css">')
|
||||
.. code-block:: python
|
||||
|
||||
from django.utils.html import format_html
|
||||
from django.contrib.staticfiles.templatetags.staticfiles import static
|
||||
|
||||
from wagtail.wagtailcore import hooks
|
||||
|
||||
@hooks.register('insert_global_admin_css')
|
||||
def global_admin_css():
|
||||
return format_html('<link rel="stylesheet" href="{}">', static('my/wagtail/theme.css'))
|
||||
|
||||
|
||||
.. _insert_editor_js:
|
||||
|
|
Ładowanie…
Reference in New Issue