Reload avoidance hack disabled for django < 2.2
from iommi._web_compat import mark_safe
import parso
-orig_reload = autoreload.trigger_reload
+orig_reload = getattr(autoreload, 'trigger_reload', None)
class Middleware:
@@ -83,6 +83,8 @@ def live_edit_view(request, view_func):
ast_of_old_code.children[:] = ast_of_new_code.children
+ # This only works in django 2.2+
+ if orig_reload is not None:
# A little monkey patch dance to avoid one reload of the runserver when it's just us writing the code to disk
def restore_auto_reload(filename):
from django.utils import autoreload
