-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Context processors prevented an initial server object from being created
- Loading branch information
Showing
1 changed file
with
19 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
from django.core.exceptions import ImproperlyConfigured | ||
from django.conf import settings | ||
|
||
from .models import Server | ||
|
||
def server_context(request): | ||
server_context = Server.objects.first() | ||
if server_context is None: | ||
raise ImproperlyConfigured( | ||
"No Server object found in the database. Tip: please add one." | ||
) | ||
if settings.ADMIN_PATH not in request.path: | ||
if server_context is None: | ||
raise ImproperlyConfigured( | ||
"No Server object found in the database. Tip: please add one." | ||
) | ||
|
||
return { | ||
"server": { | ||
"ip": server_context.ip, | ||
"production": server_context.production, | ||
return { | ||
"server": { | ||
"ip": server_context.ip, | ||
"production": server_context.production | ||
} | ||
} | ||
|
||
else: | ||
return { | ||
"server": { | ||
"ip": "", | ||
"production": "" | ||
} | ||
} | ||
} |