From 1060dfbd5313c0c85becae5d8a8db30bfb15d29c Mon Sep 17 00:00:00 2001 From: Calum Young Date: Thu, 16 Dec 2021 23:10:54 +0000 Subject: [PATCH 1/2] Add notification if script not injected --- livereload/middleware.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/livereload/middleware.py b/livereload/middleware.py index df69f29..ff7e783 100644 --- a/livereload/middleware.py +++ b/livereload/middleware.py @@ -1,6 +1,7 @@ """ Middleware for injecting the live-reload script. """ +import logging from bs4 import BeautifulSoup from django.utils.encoding import smart_str @@ -12,6 +13,7 @@ from livereload import livereload_port, livereload_host +logger = logging.getLogger("django.server") class LiveReloadScript(MiddlewareMixin): """ @@ -32,6 +34,7 @@ def process_response(self, request, response): head = getattr(soup, 'head', None) if not head: + logger.info("No head tag found. Live-reload script not injected.") return response script = soup.new_tag( From e44d90eb0fa3360f6c18a7a948c6445fc4743a0e Mon Sep 17 00:00:00 2001 From: Calum Young Date: Mon, 13 Jun 2022 14:52:46 +0100 Subject: [PATCH 2/2] Add documentation to fix #50 --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 3a73c44..da0503a 100644 --- a/README.rst +++ b/README.rst @@ -36,7 +36,7 @@ Next you need to inject the loading of the livereload javascript. You can do thi {% livereload_script %} -Either of these options will inject the ``livereload.js`` script into your webpages if ``DEBUG`` setting is on. +Either of these options will inject the ``livereload.js`` script into your webpages if ``DEBUG`` setting is on and a head tag is present. Configuration -------------