This release is a pre-release and may not be stable for production use.
core-package
Author: puzzllium · puzzllium@gmail.com · LinkedIn
Reusable Django/Ninja apps — session-JWT auth, users, RBAC, audit logging,
base models and optional Socket.IO — that you install into your own Django
project. It's the foundation for the site packages (blog, portfolio, company,
ecommerce, ...). It is a package, not a project: there are no settings, urls,
or manage.py in it.
Install
Requires Python 3.10+ and Django 5.2.
Base package
pip install core-package
Installs the required apps (apps.core, apps.users, apps.roles,
apps.events, apps.contacts) and their dependencies only — no Socket.IO, no
static-file middleware, no database driver beyond Django's built-in sqlite, no
ASGI server.
Extras
Each extra adds one optional feature. Quote the argument so the shell doesn't expand the brackets.
| Command | Adds | Needed for |
|---|---|---|
pip install "core-package[realtime]" |
python-socketio, python-engineio |
apps.realtime in INSTALLED_APPS and with_socketio() in asgi.py |
pip install "core-package[static]" |
whitenoise |
apps.core.middleware.AsyncWhiteNoiseMiddleware |
pip install "core-package[postgres]" |
psycopg[binary] |
a PostgreSQL DATABASES entry |
pip install "core-package[redis]" |
django-redis, redis |
Redis cache/sessions and multi-worker Socket.IO (REDIS_URL) |
pip install "core-package[server]" |
uvicorn[standard] |
running the project with uvicorn |
pip install "core-package[all]" |
all five above | everything |
pip install "core-package[dev]" |
realtime, static, pytest, pytest-django, pytest-asyncio |
running this package's own tests |
Extras combine with commas:
pip install "core-package[realtime,server]" # local development with Socket.IO
pip install "core-package[static,server]" # local development without Socket.IO
pip install "core-package[postgres,redis,static,server]" # production without Socket.IO
pip install "core-package[all]" # production with Socket.IO
Pinning a version
In a project's requirements.txt, pin the exact version so every machine
installs the same thing:
core-package[all]==0.2.1
Through a site package
Site packages depend on core-package, so installing one installs core-package too (base package, no extras). Add the extras you want alongside it:
pip install company-portfolio-package "core-package[realtime,server]"
Working on core-package itself
From a clone of this repo, an editable install picks up code changes without reinstalling:
pip install -e ".[dev]"
Creating a project
core-package is installed into a normal Django project. The steps below build
one from scratch (here Core/myproject, next to the Packages/ folder).
1. Folder and virtualenv
mkdir myproject && cd myproject
python -m venv .venv
source .venv/bin/activate
2. Install core-package
pip install "core-package[server]" # without Socket.IO
pip install "core-package[realtime,server]" # with Socket.IO
server installs uvicorn. pip install "core-package[all]" installs every extra.
3. Create the Django project
django-admin startproject config .
4. config/settings.py
from apps.core.defaults import CORE_APPS, CORE_MIDDLEWARE, PASSWORD_HASHERS # noqa: F401
INSTALLED_APPS = [
"unfold", # must come before django.contrib.admin
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
*CORE_APPS, # ninja, apps.core, apps.events, apps.users, apps.roles
# "apps.contacts", # optional: contact form
# "apps.realtime", # optional: Socket.IO (needs core-package[realtime])
]
MIDDLEWARE = [
# ... Django's default middleware, unchanged ...
*CORE_MIDDLEWARE, # JSON request log
]
AUTH_USER_MODEL = "users.User"
MEDIA_URL = "media/"
MEDIA_ROOT = BASE_DIR / "media"
5. config/urls.py
from django.contrib import admin
from django.urls import path
from apps.core.api import create_api
api = create_api(title="My Site API")
urlpatterns = [
path("admin/", admin.site.urls),
path("api/", api.urls),
]
create_api() adds session-JWT auth, the shared error format, GET /health
and the core routers (/auth, /roles, /events, plus /contacts if that app
is installed). Any NinjaAPI keyword (title, version, docs_url, ...) is
passed through.
6. Socket.IO (optional)
Skip this step if you don't want sockets; nothing else depends on it.
Otherwise install core-package[realtime], uncomment "apps.realtime" in
INSTALLED_APPS, and replace config/asgi.py with:
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
django_asgi_app = get_asgi_application()
from apps.realtime.asgi import with_socketio # noqa: E402
application = with_socketio(django_asgi_app)
7. Database and admin user
python manage.py migrate
python manage.py seed_roles # default "admin" and "user" roles
python manage.py createsuperuser
8. Run
uvicorn config.asgi:application --reload # required for Socket.IO
python manage.py runserver # fine without Socket.IO
- API docs:
http://localhost:8000/api/docs - Admin:
http://localhost:8000/admin/
9. Add site packages (e.g. a company portfolio site)
Site packages are installed the same way and mounted on the API. For a
company site, install company-portfolio-package (it pulls in portfolio-package and
blog-package), then:
# settings.py: after *CORE_APPS, in this order
*CORE_APPS,
"blog",
"portfolio",
"company",
# urls.py
from blog.api import router as blog_router
from company.api import router as company_router
from portfolio.api import router as portfolio_router
api = create_api(title="My Site API")
api.add_router("/blog", blog_router)
api.add_router("/portfolio", portfolio_router)
api.add_router("/company", company_router)
python manage.py migrate
10. Frontend on another origin (CORS)
CORS is the host project's job, not the package's:
pip install django-cors-headers
INSTALLED_APPS += ["corsheaders"]
# put "corsheaders.middleware.CorsMiddleware" before CommonMiddleware in MIDDLEWARE
CORS_ALLOWED_ORIGINS = ["http://localhost:3000"]
CSRF_TRUSTED_ORIGINS = ["http://localhost:3000"]
CORS_ALLOW_CREDENTIALS = True # auth uses the session cookie
Settings
All optional — the package falls back to these defaults
(apps/core/conf.py):
| Setting | Default |
|---|---|
JWT_SIGNING_KEY |
SECRET_KEY |
JWT_ACCESS_TOKEN_LIFETIME_MINUTES |
60 |
REDIS_URL |
"" (Socket.IO uses the in-process manager) |
CORS_ALLOWED_ORIGINS |
[] (Socket.IO allowed origins) |
KAVENEGAR_API_KEY |
"" (OTP codes are logged instead of sent) |
KAVENEGAR_OTP_TEMPLATE |
"verify" |
For the JSON audit log file, set LOGGING = build_logging_config(BASE_DIR / "logs")
from apps.core.logging.
What's inside
| App | Required | Purpose |
|---|---|---|
apps.core |
yes | Session-bound JWT auth, permissions, middleware, pagination, throttling, exceptions, audit logging, SMS helper, create_api() |
apps.users |
yes | User model and user/auth API |
apps.roles |
yes | Role-based access control (RBAC) |
apps.events |
yes | Audit events model, API and admin |
apps.contacts |
no | Contact messages model, API and admin |
apps.realtime |
no | Socket.IO server with session/JWT authentication |
Development
pip install -e ".[dev]"
pytest # runs against testproject/ (not shipped in the wheel)
Dependencies
Version ranges are used (this is a library), so it won't conflict with the host project.
Required
| Package | Used for |
|---|---|
Django >=5.2,<5.3 |
Web framework |
django-ninja >=1.4,<2 |
REST API layer |
asgiref >=3.8 |
Async support |
email-validator >=2.2,<3 |
Email validation |
argon2-cffi >=23 |
Password hashing |
PyJWT >=2.8,<3 |
JWT tokens |
django-unfold >=0.60 |
Admin theme |
Pillow >=10 |
Image handling |
requests >=2.31,<3 |
SMS (Kavenegar) HTTP client |
Optional extras
| Extra | Installs | For |
|---|---|---|
realtime |
python-socketio, python-engineio |
apps.realtime |
static |
whitenoise |
apps.core.middleware.AsyncWhiteNoiseMiddleware |
postgres |
psycopg[binary] |
PostgreSQL |
redis |
django-redis, redis |
Cache/sessions, multi-worker Socket.IO |
server |
uvicorn[standard] |
ASGI server |
all |
all of the above |
License
MIT. See LICENSE.
Metadata
Release files for core-package 0.3.0.dev0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| core_package-0.3.0.dev0.tar.gz | 69.2 kB | With provenance | Details for core_package-0.3.0.dev0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| core_package-0.3.0.dev0-py3-none-any.whl | Python 3 | none | any | Details for core_package-0.3.0.dev0-py3-none-any.whl |
Total release size: 159.4 kB
Release files / core_package-0.3.0.dev0.tar.gz
| Download URL | core_package-0.3.0.dev0.tar.gz |
|---|---|
| Size | 69.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dee5ace17236db999245661eba8f3ac55992fa8e31f307e0690a629aff035829
|
|
BLAKE2b-256 checksum How to use checksums |
dfc8630b3e6f0dd580125caa7e3dd5ffb2257436cff5cf9cad0156688a4efbca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / core_package-0.3.0.dev0-py3-none-any.whl
| Download URL | core_package-0.3.0.dev0-py3-none-any.whl |
|---|---|
| Size | 90.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a1acff2c75419c8087ede02b3273bfdc2ff6433594a51059c7b3d0855372657
|
|
BLAKE2b-256 checksum How to use checksums |
8151cd8854bad6a1fd12c00e841396708fc7cee40cc001ba9ad5c14dff3b9e7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for core-package 0.3.0.dev0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for core_package-0.3.0.dev0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.