Reusable Django and DRF helpers for pagination, model auditing, admin tracking, and serializers
Project description
Django Tools Pack Usage Guide
This guide is for application developers who want to install the package and use it directly in their Django project.
1) Install
pip install djangotoolspack
2) Add to INSTALLED_APPS
In your Django settings:
INSTALLED_APPS = [
# your apps...
"djangotoolspack",
]
3) Import what you need
from djangotoolspack import (
TimestampedMixin,
UserTrackedMixin,
AuditLogMixin,
AdminMixin,
SerializerMixin,
StandardPaginationResult,
)
4) Use mixins in models
from django.db import models
from djangotoolspack import AuditLogMixin
class Product(AuditLogMixin, models.Model):
name = models.CharField(max_length=120)
price = models.DecimalField(max_digits=10, decimal_places=2)
What you get automatically:
created_atupdated_atcreated_byupdated_by
5) Use AdminMixin in Django admin
from django.contrib import admin
from djangotoolspack import AdminMixin
from .models import Product
@admin.register(Product)
class ProductAdmin(AdminMixin):
list_display = ("id", "name", "created_at", "updated_at")
AdminMixin sets:
created_bywhen object is first created in adminupdated_byon every admin save
6) Use SerializerMixin for file URLs and field ordering
from rest_framework import serializers
from djangotoolspack import SerializerMixin
from .models import Product
class ProductSerializer(SerializerMixin, serializers.ModelSerializer):
class Meta:
model = Product
fields = ["id", "name", "image", "price"]
# Converts file fields to URL (or None)
file_fields = ["image"]
# Moves listed fields to the end in this exact order
fields_ordering = ["price", "id"]
7) Use StandardPaginationResult in API views
from rest_framework.views import APIView
from djangotoolspack import StandardPaginationResult
from .models import Product
from .serializers import ProductSerializer
class ProductListApi(APIView):
def get(self, request):
queryset = Product.objects.all().order_by("-id")
paginator = StandardPaginationResult()
page_items = paginator.paginate_queryset(queryset, request, view=self)
serializer = ProductSerializer(page_items, many=True)
return paginator.get_paginated_response(
serializer.data,
message="Products fetched successfully",
status_code=200,
)
Supported query params:
pagepage_size
Typical import pattern
Import directly from the package root:
from djangotoolspack import AuditLogMixin, StandardPaginationResult
If you need any help then please contact with use.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file djangotoolspack-0.0.2.tar.gz.
File metadata
- Download URL: djangotoolspack-0.0.2.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
882d06ecff312ecba421e3cfbb7a21475504c650abe06285f4a5da2279cfe694
|
|
| MD5 |
e52149c7443e70154658c20dc9d158fa
|
|
| BLAKE2b-256 |
c177ab65fd76aec0ca80cb1f2bcb0d67a12164db85ec9e2ac4c262d7f968d07c
|
Provenance
The following attestation bundles were made for djangotoolspack-0.0.2.tar.gz:
Publisher:
python-publish.yml on chinmayroy/djangotoolspack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djangotoolspack-0.0.2.tar.gz -
Subject digest:
882d06ecff312ecba421e3cfbb7a21475504c650abe06285f4a5da2279cfe694 - Sigstore transparency entry: 1436979253
- Sigstore integration time:
-
Permalink:
chinmayroy/djangotoolspack@7d94d154efb16950fec351f9a6417d4e07b67533 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/chinmayroy
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7d94d154efb16950fec351f9a6417d4e07b67533 -
Trigger Event:
release
-
Statement type:
File details
Details for the file djangotoolspack-0.0.2-py3-none-any.whl.
File metadata
- Download URL: djangotoolspack-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e3b4bcec6ab3656b216763b7b3926d35d38491b023f33f6b636a53dbbe6e0c9
|
|
| MD5 |
f16c55cfdd16ca4674c215d29b0a6245
|
|
| BLAKE2b-256 |
d10a1c9670e9ff992a459dc75201ee46bd0082d3622fdc9ac705cf92946fd7d5
|
Provenance
The following attestation bundles were made for djangotoolspack-0.0.2-py3-none-any.whl:
Publisher:
python-publish.yml on chinmayroy/djangotoolspack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djangotoolspack-0.0.2-py3-none-any.whl -
Subject digest:
9e3b4bcec6ab3656b216763b7b3926d35d38491b023f33f6b636a53dbbe6e0c9 - Sigstore transparency entry: 1436979254
- Sigstore integration time:
-
Permalink:
chinmayroy/djangotoolspack@7d94d154efb16950fec351f9a6417d4e07b67533 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/chinmayroy
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@7d94d154efb16950fec351f9a6417d4e07b67533 -
Trigger Event:
release
-
Statement type: