From 7523d7f57f9e2498cf09f03ac7f5fa796895b190 Mon Sep 17 00:00:00 2001 From: Robert Rollins Date: Wed, 27 Apr 2016 17:27:32 -0700 Subject: [PATCH] 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. --- .../customisation/branding.rst | 6 ++-- docs/reference/hooks.rst | 33 +++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/docs/advanced_topics/customisation/branding.rst b/docs/advanced_topics/customisation/branding.rst index 4051b5c7b1..b998cda863 100644 --- a/docs/advanced_topics/customisation/branding.rst +++ b/docs/advanced_topics/customisation/branding.rst @@ -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 %} - Custom Project + Custom Project {% 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 %} - + {% endblock %} ``branding_login`` diff --git a/docs/reference/hooks.rst b/docs/reference/hooks.rst index 89ba53584f..f2872c3c4c 100644 --- a/docs/reference/hooks.rst +++ b/docs/reference/hooks.rst @@ -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('') + return format_html( + '', + 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('') + .. 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('', static('my/wagtail/theme.css')) .. _insert_editor_js: