From 773f1332ee4458cce5d5e0be25fb350ffebdc4f0 Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Thu, 16 Jun 2016 11:42:08 +0100 Subject: [PATCH] Fix import earliness for auth model --- channels/auth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/channels/auth.py b/channels/auth.py index 0565446..06e826b 100644 --- a/channels/auth.py +++ b/channels/auth.py @@ -1,7 +1,6 @@ import functools from django.contrib import auth -from django.contrib.auth.models import AnonymousUser from .sessions import channel_session, http_session @@ -30,6 +29,8 @@ def channel_session_user(func): if not hasattr(message, "channel_session"): raise ValueError("Did not see a channel session to get auth from") if message.channel_session is None: + # Inner import to avoid reaching into models before load complete + from django.contrib.auth.models import AnonymousUser message.user = AnonymousUser() # Otherwise, be a bit naughty and make a fake Request with just # a "session" attribute (later on, perhaps refactor contrib.auth to