2 install
Christian Moser edited this page 2026-06-04 02:15:56 +02:00

Installation

Add TinyUser to your project using poetry

poetry add https+git://codeberg.org/c9moser/django-tinyuser.git

Configuration of your project


...
# Register allauth and django_tinyuser
APPS = [
    ...
    'allauth',
    'allauth.account',
    'allauth.socialaccount', # if you want to use social auth
    # add the providers you want to use, e.g. 'allauth.socialaccount.providers.google',
    'django_tinyuser',
    # optionally add the drf framework if you want to use the API endpoints of django-tinyuser
    'rest_framework',
    # optionally add drf_spectacular if you want to use the API documentation of django-tinyuser
    'drf_spectacular',
    # optionally add drf_spectacular_sidecar if you want to use the API documentation of django-tinyuser with the sidecar UI
    'drf_spectacular_sidecar',
    # finally add tinyuser webapi if you want to use the API endpoints of django-tinyuser
    'django_tinyuser.webapi',
    ...
]

If you use Bootstrap, you can add overloads to your TEMPLATES. The overloads are located in the global_templates folder of django_tinyuser. You can add them to your TEMPLATES like this is and they will be used instead of the default templates of django-allauth.

Note that you have to add the path to the overloads before the default templates of django-allauth, otherwise they will not be used.

And don't forget to add the context processors for django-allauth, and django-tinyuser, otherwise the templates will not work.

from django_tinyuser.global_templates.bootstrap import PATH as TINYUSER_GLOBAL_TEMPLATES
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        # Add Bootstrap overloads to TEMPLATES
        'DIRS': [TINYUSER_GLOBAL_TEMPLATES],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                ...
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django_tinyuser.context_processors.tinyuser'
                ...
            ],
        },
    },
...
]

If you use Tailwind CSS, you can add the overloads to your TEMPLATES like this is and they will be used instead of the default templates of django-allauth.

from django_tinyuser.global_templates.tailwindcss import PATH as TINYUSER_GLOBAL_TEMPLATES
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        # Add Tailwind CSS overloads to TEMPLATES
        'DIRS': [TINYUSER_GLOBAL_TEMPLATES],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                ...
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
                'django_tinyuser.context_processors.tinyuser'
                ...
            ],
        },
    },
...
]

You also need to set the CSS_FRAMEWORK option in your settings.py to the css framework you use, otherwise the templates will not work.

CSS_FRAMEWORK = 'bootstrap' # if you use Bootstrap
# or
CSS_FRAMEWORK = 'tailwindcss' # if you use Tailwind CSS
# or
CSS_FRAMEWORK = 'custom' # if you use custom templates

And you need to set the AUTH_USER_MODEL to django_tinyuser.TinyUser in your settings.py or to an overloaded model if you have customized the user model.

AUTH_USER_MODEL = 'django_tinyuser.TinyUser'

Then add the urls of django-allauth to your urls.py

from django.urls import path, include
urlpatterns = [
    ...
    path('accounts/', include('allauth.urls')),
    path('user/', include('django_tinyuser.urls')),
    # optionally add the urls for the API documentation of django-tinyuser if you want to use it
    path('schema/', SpectacularAPIView.as_view(), name='schema'),
    path('docs/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger'),
    # finally add the urls for the API endpoints of django-tinyuser if you want to use them
    path('api/', include('django_tinyuser.webapi.urls')),
    ...
]

Finally run the migrations to create the required tables added by required apps, django-allauth and django-tinyuser.

    python manage.py migrate