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.0.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.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pidalu_core-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 f7f0b0f7a4dcc967ab9c9e9b790b71721922e57b1f1da723f3ec5bf4a795844c
MD5 f5c772b8f9e0cdb05b6c619d5436187b
BLAKE2b-256 1a98c8c7477185882f2377261bb54cacebe0d945640830819cb4f13962a07138

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pidalu_core-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6284b007d0784952af93556a2c8fe6cd99807b72790e451c888d34d51c085ab
MD5 c411dbec405a0b3d46979da60e26b2e0
BLAKE2b-256 a3caf15b9a193dfd2fca78b4739d535583b83e52bbc49f2a2505eb4cf6543509

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