Skip to main content

dj3base

English | 简体中文

dj3base contains some small tools for Django.

1. Introduction

  • admin: Use OrderedAdminSite to customize the order of apps and models.
  • views: Use PostJsonView to handle POST-JSON-style requests.
  • utils: Some utility functions.

2. Usage

Install

pip install dj3base

Examples

  • OrderedAdminSite
from django.contrib.auth.models import User, Group
from django.contrib.auth.admin import UserAdmin, GroupAdmin
from django.contrib.auth.apps import AppConfig
from dj3base.admin.ordered_admin_site import OrderedAdminSite


class MyAdminSite(OrderedAdminSite):
    ordered_apps = {
        AppConfig: {
            "index": 1,
            "models": {
                Group: {"index": 1},
                User: {"index": 2},
            }
        }
    }


my_admin_site = OrderedAdminSite(name='my_admin')
my_admin_site.register(User, UserAdmin)
my_admin_site.register(Group, GroupAdmin)

# in urls.py
from django.urls import path

urlpatterns = [
    path('admin/', my_admin_site.urls),
]
  • PostJsonView
from dj3base.views import PostJsonView
from a3json_struct import struct


class RequestStruct(struct.JsonStruct):
    message: str = struct.CharField(min_length=1, max_length=10)

    
class EchoView(PostJsonView):
    request_struct_cls = RequestStruct

    def handle_post(self, request_struct: RequestStruct, custom_params: dict) -> dict:
        return {"message": f"hello {request_struct.message}"}

Metadata

Release files for dj3base 0.3.1

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

Source distribution (sdist)

Source distribution for dj3base 0.3.1
File Size Uploaded
dj3base-0.3.1.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dj3base 0.3.1
File Interpreter ABI Platform
dj3base-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 22.9 kB

Release files / dj3base-0.3.1.tar.gz

Download URL dj3base-0.3.1.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bd5dff83cc40ab11a85da58056409d3a9d7227fdef30c69250dff0b0820e270f
BLAKE2b-256 checksum
How to use checksums
f0383eb9c05ee4ddf24a4c810a9a996be851d81aaf6662aa39c340c62fc2b4ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Release files / dj3base-0.3.1-py3-none-any.whl

Download URL dj3base-0.3.1-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
413a615e7c772e06cdffd61734d0e34a27bb3023d48d373c40820a5f09b02b31
BLAKE2b-256 checksum
How to use checksums
cdb53e946f0ba7b288069ddbff89ac9e8f8d7997480eed3384373a09206b5a6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.1.7

1 release file

0.1.6

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

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