A fast initial setup for Django projects, providing a custom user model, authentication forms, and admin configuration.
Project description
django-base-kit
A bootstrap library for Django projects with:
- an abstract
BaseModelusing UUID v4 as the primary key - a custom
Usermodel (AbstractUser+BaseModel) - ready-to-use authentication views and templates:
- login
- logout
- change password
- password reset ("forgot password")
Installation
pip install django-base-kit
What this package provides
1) Reusable BaseModel
File: django_base_kit.models.BaseModel
Included fields:
id(UUIDField,primary_key=True,default=uuid.uuid4)created_atupdated_atactive
Example usage in any app:
from django.db import models
from django_base_kit.models import BaseModel
class Product(BaseModel):
name = models.CharField(max_length=120)
price = models.DecimalField(max_digits=10, decimal_places=2)
def __str__(self):
return self.name
2) Custom User model
File: django_base_kit.models.User
- inherits from
BaseModel - inherits from
AbstractUser - unique
email - model app label:
base_kit
So in settings.py, use:
AUTH_USER_MODEL = "base_kit.User"
3) Auth stack (views + forms + templates)
The package already includes forms, views, and templates for:
- login
- logout
- change password
- password reset (form, done, confirm, complete)
Routes are exposed through django_base_kit.urls.user_urlpatterns.
Consumer project setup
1) settings.py
Add/update:
INSTALLED_APPS = [
# django apps...
"widget_tweaks",
"django_base_kit",
]
AUTH_USER_MODEL = "base_kit.User"
# Email sender used by password reset views
# The view reads FROM_MAIL and falls back to DEFAULT_FROM_EMAIL
FROM_MAIL = "no-reply@example.com"
DEFAULT_FROM_EMAIL = FROM_MAIL
# Local development (prints emails in the console)
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
# Recommended so Django can find package templates
TEMPLATES = [
{
# ...
"APP_DIRS": True,
},
]
2) Project urls.py
from django.contrib import admin
from django.urls import path
from django_base_kit.urls import user_urlpatterns
urlpatterns = [
path("admin/", admin.site.urls),
] + user_urlpatterns
3) Migrations
In a new project:
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
Available routes
/accounts/signup//accounts/login//accounts/logout//change_password//reset_password//reset_password/done/reset_password/confirm/<uidb64>/<token>//reset_password/complete/
Important notes
- Set
AUTH_USER_MODEL = "base_kit.User"before your first migration. - If your project already migrated with
auth.User, you will need a user migration plan. - For password reset in production, configure SMTP (
EMAIL_HOST,EMAIL_PORT,EMAIL_HOST_USER,EMAIL_HOST_PASSWORD,EMAIL_USE_TLS/SSL).
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django_base_kit-0.0.1.tar.gz
(10.6 kB
view details)
File details
Details for the file django_base_kit-0.0.1.tar.gz.
File metadata
- Download URL: django_base_kit-0.0.1.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f99fbfd7a6827fe4f789b30075e431d396b1c4d00d7f1068b194b27e162ea8d7
|
|
| MD5 |
8af02b2dd0b59172eb1a09ce269a81fc
|
|
| BLAKE2b-256 |
40253bb1a498d994ecc37059c1b00233aa9b8728af629f6bf73b7b2355ff7325
|