Skip to content

Commit

Permalink
Add notification if script not injected
Browse files Browse the repository at this point in the history
  • Loading branch information
calumy committed Dec 16, 2021
1 parent a94c3a1 commit 1060dfb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions livereload/middleware.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Middleware for injecting the live-reload script.
"""
import logging
from bs4 import BeautifulSoup

from django.utils.encoding import smart_str
Expand All @@ -12,6 +13,7 @@

from livereload import livereload_port, livereload_host

logger = logging.getLogger("django.server")

class LiveReloadScript(MiddlewareMixin):
"""
Expand All @@ -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(
Expand Down

0 comments on commit 1060dfb

Please sign in to comment.