Skip to main content

Pidalu Tech - Resusable core models, serializers and middlewares

Project description

pidalu-core

Reusable Django core utilities and base components for Django and Django REST Framework projects.

Includes model mixins, serializer tools, queryset managers, admin helpers, and middleware.
Designed to work out of the box with settings.py overrides.


🚀 Features

✅ Models & Mixins

  • TimeStampedModel – auto created_at, updated_at
  • UserTrackerModel – auto created_by, updated_by
  • TrackedModel – combo of the above
  • SlugFieldModel – auto slug from any source field
  • UUIDPrimaryKeyModel – use UUIDs as primary keys
  • SoftDeleteModel – soft deletion with manager/queryset support
  • AuditModel – tracks and logs field-level changes

🔁 QuerySet & Manager Extensions

  • SoftDeleteManager.only_deleted(), .with_deleted(), .active()
  • SoftDeleteQuerySet – compatible with manager above

📦 Serializers

  • DynamicFieldsModelSerializer – limit output via fields=[...]
  • DynamicSerializer – same for plain serializers
  • DummySerializer – no-op placeholder
  • (All located in pidalu_core.serializers)

🛠 Admin Helpers

  • ReadOnlyAdminFieldsMixin – make selected fields readonly
  • AutoSlugAdminMixin – auto-prepopulate slug in admin from any field

🧠 Middleware

  • RequestMiddleware – stores current request in thread-local

    Used to track created_by/updated_by automatically in models


⚙️ Installation

pip install pidalu-core

Or using Poetry:

poetry add pidalu-core

🧩 Setup

1. Add Middleware

# settings.py
MIDDLEWARE = [
    "pidalu_core.middleware.request.RequestMiddleware",  # ✅ Add near top
    ...
]

2. Optional Settings

# settings.py

PIDALU_CORE_TRACK_USER = True  # enable tracking created_by/updated_by
PIDALU_CORE_AUTO_SLUG_FIELD = "name"  # default source field for slug generation

🧱 Usage Examples

TrackedModel (timestamps + user)

from pidalu_core.models import TrackedModel

class Post(TrackedModel):
    title = models.CharField(max_length=100)

SlugFieldModel with custom source

class Article(SlugFieldModel):
    title = models.CharField(max_length=255)
    slug_source_field = "title"

SoftDeleteModel with manager

class Project(SoftDeleteModel):
    name = models.CharField(max_length=255)

# Usage:
Project.objects.all()  # active only
Project.objects.only_deleted()
Project.objects.with_deleted()

DynamicFieldsModelSerializer

class UserSerializer(DynamicFieldsModelSerializer):
    class Meta:
        model = User
        fields = ["id", "username", "email"]

# usage: UserSerializer(user, fields=["id", "email"])

🧪 Testing

Use Makefile> test.

Setup

make test

Or directly with Poetry, uses pytest and pytest-django under the hood:

PYTHONPATH=. poetry run pytest -vv

We use in-memory SQLite + dynamic schema creation.


📦 Packaging & Publishing

Coming soon:

  • Versioned releases
  • PyPI support
  • Docs site

👤 Author

Built and maintained by [Pidalu].


🪪 License

MIT License — free to use, modify, and distribute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pidalu_core-0.1.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pidalu_core-0.1.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file pidalu_core-0.1.1.tar.gz.

File metadata

  • Download URL: pidalu_core-0.1.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.11 Linux/6.11.0-1015-azure

File hashes

Hashes for pidalu_core-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b3c24cbf6190758468cc6d96979d3f60583dd881950c90f1a7788cc34015cbec
MD5 363ab57a028e9b34bc3b0519c8f523fe
BLAKE2b-256 b5efae55f3edab607795f49b4850872ad39ca15aebae816ce2b184b551c69871

See more details on using hashes here.

File details

Details for the file pidalu_core-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pidalu_core-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.11 Linux/6.11.0-1015-azure

File hashes

Hashes for pidalu_core-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a004abfd584f7dea4ae4ef61a24bf8becad28bb76ccfab3a097f6893c1aa2406
MD5 b9393d1f4e2d30b9639464ea0f616fb1
BLAKE2b-256 4618202547b3f46de98cf629d32256d3909617636be599420a7277790905683a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page