Customizing
It is possible to customize your Alliance Auth instance.
Warning
Keep in mind that you may need to update some of your customizations manually after new Auth releases (e.g., when replacing templates).
Site name
You can replace the default name shown on the website with your own, e.g., the name of your Alliance.
Just update SITE_NAME
in your local.py
settings file accordingly, e.g.:
SITE_NAME = 'Awesome Alliance'
Custom Static and Templates
Within your auth project exists two folders named static
and templates
. These are used by Django for rendering web pages. Static refers to content Django does not need to parse before displaying, such as CSS styling or images. When running via a WSGI worker such as Gunicorn, static files are copied to a location for the web server to read from. Templates are always read from the template folders, rendered with additional context from a view function, and then displayed to the user.
You can add extra static or templates by putting files in these folders. Note that changes to static require running the python manage.py collectstatic
command to copy to the web server directory.
It is possible to overload static and templates shipped with Django or Alliance Auth by including a file with the exact path of the one you wish to overload. For instance if you wish to add extra links to the menu bar by editing the template, you would make a copy of the allianceauth/templates/allianceauth/base-bs5.html
(Bootstrap 5) allianceauth/templates/allianceauth/base.html
(Legacy BS3) file to myauth/templates/allianceauth/*.html
and edit it there. Notice the paths are identical after the templates/
directory - this is critical for it to be recognized. Your custom template would be used instead of the one included with Alliance Auth when Django renders the web page. Similar idea for static: put CSS or images at an identical path after the static/
directory and they will be copied to the web server directory instead of the ones included.
Custom URLs and Views
It is possible to add or override URLs with your auth project’s URL config file. Upon installing, it is of the form:
from django.urls import re_path
from django.urls import include
import allianceauth.urls
urlpatterns = [
re_path(r'', include(allianceauth.urls)),
]
This means every request gets passed to the Alliance Auth URL config to be interpreted.
If you wanted to add a URL pointing to a custom view, it can be added anywhere in the list if not already used by Alliance Auth:
from django.urls import re_path
from django.urls import include, path
import allianceauth.urls
import myauth.views
urlpatterns = [
re_path(r'', include(allianceauth.urls)),
path('myview/', myauth.views.myview, name='myview'),
]
Additionally, you can override URLs used by Alliance Auth here:
from django.urls import re_path
from django.urls import include, path
import allianceauth.urls
import myauth.views
urlpatterns = [
path('account/login/', myauth.views.login, name='auth_login_user'),
re_path(r'', include(allianceauth.urls)),
]