Skip to main content

Django Essentials

Essential utilities for Django that make common tasks easier and more efficient.

Features

  • Admin Utilities: Enhanced admin interface components including FancyBox image display
  • Model Utilities: Helper functions for common model operations

Installation

pip install django-essentials-kit

Quick Start

Admin Utilities

The library provides MediaFancybox class and get_fancybox_image function for enhanced image display in Django admin:

from django.contrib import admin
from django_essentials_kit.admin import MediaFancybox, get_fancybox_image
from .models import YourModel

@admin.register(YourModel)
class YourModelAdmin(admin.ModelAdmin):
    list_display = ['name', 'image_preview']

    class Media(MediaFancybox):
        ...

    def image_preview(self, obj) -> SafeString:
        return get_fancybox_image(obj, 'image_field', w=60, h=60)

Model Utilities

Use get_object_or_none for safe object retrieval:

from django_essentials_kit.utils import get_object_or_none

from .models import YourModel

# Instead of try/except blocks
obj = get_object_or_none(YourModel, pk=1)
if obj:
    ...  # Do something with obj

JSON Logger Formatter

Add to settings.py:

LOGGING = {
    "version": 1,
    "disable_existing_loggers": True,
    "root": {"level": "INFO", "handlers": ["console"]},
    "formatters": {
        "json": {
            "format": "[%(levelname)s][%(asctime)s] %(module)s.%(funcName)s:%(lineno)d: %(message)s",
            "()": "django_essentials_kit.logger_formatter.JSONFormatter",
        },
    },
    "handlers": {
        "console": {"level": "INFO", "class": "logging.StreamHandler", "formatter": "json"},
    },
    "loggers": {
        "django": {"level": "DEBUG", "handlers": ["console"], "propagate": False},
        # ...
    },
}

Logging HTTP request-response

Add to settings.py:

MIDDLEWARE = [
    "django_essentials_kit.middlewares.DjangoLoggingMiddleware",
    # ...
]

It will be added to the logs:

  • real_client_ip if it is routable
  • is_succeeded (200 <= status < 300 - true else false)
  • request details:
    • status_code
    • method
    • path
  • user_id if a user is signed in
  • real_client_ip (if routable)

Requirements

  • Python 3.8+
  • Django 3.2+

License

MIT License - see LICENSE file for details.

Metadata

Release files for django-essentials-kit 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-essentials-kit 0.1.6
File Size Uploaded Provenance
django_essentials_kit-0.1.6.tar.gz 8.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-essentials-kit 0.1.6
File Interpreter ABI Platform
django_essentials_kit-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 18.2 kB

Release files / django_essentials_kit-0.1.6.tar.gz

Download URL django_essentials_kit-0.1.6.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
35d0721dbc59098e2fddf8476b9f2ab6bc1a3093630be431e9d33fd9f31b0e51
BLAKE2b-256 checksum
How to use checksums
4995e35743178b7371ecb81c4f2bc49cf574d22dfc012b06cbd46a3f5cd41690
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / django_essentials_kit-0.1.6-py3-none-any.whl

Download URL django_essentials_kit-0.1.6-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c0b09c8a3264a649dc9643f7441348a03dfe27e76da153aacb22d86860db329
BLAKE2b-256 checksum
How to use checksums
fe8fbf5d11f851d0f8a18699a0b918dbef74c55d8dc7428981a18feb04942045
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Security for django-essentials-kit 0.1.6

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page