Django Rest API with auth
License: MIT
Moved to settings.
- Python
3.13 uv- PostgreSQL running locally
uv sync --lockedThis project only reads values from .env when DJANGO_READ_DOT_ENV_FILE=True is set. Create a .env file in the repository root with at least the below. Or alternatively, configure the .zshrc file in your home directory to contain these values.
DJANGO_READ_DOT_ENV_FILE=True
DJANGO_SETTINGS_MODULE=config.settings.local
DJANGO_DEBUG=True
MARTINI_DATABASE_URL=postgres://postgres@127.0.0.1:5432/martiniMARTINI_DATABASE_URL is the database setting used by config/settings/base.py. If you want to use a different database name, change the value in .env to match.
Examples:
MARTINI_DATABASE_URL=postgres://postgres@127.0.0.1:5432/helloworldCreate a local Postgres database with the same name used in MARTINI_DATABASE_URL.
If you are using the default value from above:
createdb martiniIf you changed the database name, create that database instead.
uv run python manage.py migrateuv run python manage.py createsuperuseruv run python manage.py runserverThe app will be available at http://127.0.0.1:8000.
This repo mounts django-allauth headless routes at /_allauth/. In allauth headless mode, the API paths are grouped by client type:
/_allauth/browser/v1/.../_allauth/app/v1/...
Basic endpoints you will commonly use include:
/_allauth/{client}/v1/auth/session/_allauth/{client}/v1/auth/login/_allauth/{client}/v1/auth/signup/_allauth/{client}/v1/auth/password/request/_allauth/{client}/v1/auth/password/reset/_allauth/{client}/v1/auth/email/verify/_allauth/{client}/v1/auth/provider/*
{client} is typically either browser or app, depending on how your frontend authenticates.
For the complete and authoritative endpoint list, including request methods, schemas, MFA flows, provider-specific routes, and OpenAPI details, see the official allauth headless docs:
-
To create a normal user account, just go to Sign Up and fill out the form. Once you submit it, you'll see a "Verify Your E-mail Address" page. Go to your console to see a simulated email verification message. Copy the link into your browser. Now the user's email should be verified and ready to go.
-
To create a superuser account, use this command:
uv run python manage.py createsuperuser
For convenience, you can keep your normal user logged in on Chrome and your superuser logged in on Firefox (or similar), so that you can see how the site behaves for both kinds of users.
Running type checks with mypy:
uv run mypy extra_dry_martini
To run the tests, check your test coverage, and generate an HTML coverage report:
uv run coverage run -m pytest
uv run coverage html
uv run open htmlcov/index.html
uv run pytest
Moved to Live reloading and SASS compilation.
This app comes with Celery.
To run a celery worker:
cd extra_dry_martini
uv run celery -A config.celery_app worker -l infoPlease note: For Celery's import magic to work, it is important where the celery commands are run. If you are in the same folder with manage.py, you should be right.
To run periodic tasks, you'll need to start the celery beat scheduler service. You can start it as a standalone process:
cd extra_dry_martini
uv run celery -A config.celery_app beator you can embed the beat service inside a worker with the -B option (not recommended for production use):
cd extra_dry_martini
uv run celery -A config.celery_app worker -B -l infoThe following details how to deploy this application.