Common base for all SFI projects based on Django.
- Authentication with SFI SSO and auto user creation
- Consistent base template with top navbar
- Perfectionist's touches (e.g. l10n fixes)
pip install -e git+https://git.sfi.pl/scm/djbase/django-sfibase.git#egg=django-sfibase
- In your
settings.py
:- At the top, add:
from sfi_base.base_settings import *
- Add to your
INSTALLED_APPS
list:INSTALLED_APPS = [ # Django apps 'sfi_base', # Your apps ]
- Add to your
MIDDLEWARE
list:MIDDLEWARE = [ ... 'mozilla_django_oidc.middleware.SessionRefresh', 'sfi_base.middleware.TryAuthenticateMiddleware', 'sfi_base.middleware.ForceAdminInEnglish', ]
- Modify your
AUTHENTICATION_BACKENDS
:AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', 'sfi_base.auth.OIDCAuthenticationBackend', )
- At the top, add:
- In your
urls.py
, add:from django.urls import include from mozilla_django_oidc.urls import OIDCAuthenticateClass urlpatterns = [ ... path('admin/login/', OIDCAuthenticateClass.as_view()), # admin site urls path('oidc/', include('sfi_base.urls')), ... ]
- In your base template file, use:
{% extends "sfi_base/base.html" %}
Please note that you need to run your development server using port 8000 - otherwise SSO won't allow you to sign in.