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}"}

Download files

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

Source Distribution

dj3base-0.3.1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

dj3base-0.3.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file dj3base-0.3.1.tar.gz.

File metadata

  • Download URL: dj3base-0.3.1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for dj3base-0.3.1.tar.gz
Algorithm Hash digest
SHA256 bd5dff83cc40ab11a85da58056409d3a9d7227fdef30c69250dff0b0820e270f
MD5 3f2096cdea456d37b0438c51b7ee8f4d
BLAKE2b-256 f0383eb9c05ee4ddf24a4c810a9a996be851d81aaf6662aa39c340c62fc2b4ae

See more details on using hashes here.

File details

Details for the file dj3base-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: dj3base-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for dj3base-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 413a615e7c772e06cdffd61734d0e34a27bb3023d48d373c40820a5f09b02b31
MD5 32d9026a1bee675b4527dbd1588366dc
BLAKE2b-256 cdb53e946f0ba7b288069ddbff89ac9e8f8d7997480eed3384373a09206b5a6a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 files

0.3.0

2 files

0.1.7

1 file

0.1.6

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

Supported by

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