Helpers to extend Django Admin with data from external service with minimal hacks

Overview

django-admin-data-from-external-service

Helpers to extend Django Admin with data from external service with minimal hacks

Live demo with sources on Heroku free quota (please be patient, it will take some time for the app to wake up)

Main features:

  • reuse Django Admin layout to simplify customization of viewing and managing external data (list/view/filter+search/ordering)
  • datasource agnostic
  • django2.x and django3.x support

How it works

Used custom ChangeList to determine method to pull external data and mock paginator behaviour.

Example

, "items": }` def get_list(self, request, page_num, list_per_page): # 2.1 pull data from some service, where # search = request.GET.get('q') # order_by = request.GET.get('o') # some_list_filter = request.GET.get('some_list_filter') data = { 'total': 1, 'users': [ {'id': 1, 'username': 'User1'}, ] } # 2.2 map data to model instances items = [ExternalUser(**i) for i in data.get("users") or []] return { "total": data.get("total") or 0, "items": items, } # 3. other standart django admin customization def get_object(self, request, object_id, *args, **kwargs): # 3.1 fetch object from external service user = {'id': 1, 'username': 'User1'}, # 3.2 map data to model instance return ExternalUser(**user) admin.site.register(ExternalUser, ExternalUserAdmin) ">
from django.db import models
from django.contrib import admin

from dadfes.admin import DfesAdminModelMixin


# Declare model for external data (managed: false)
class ExternalUser(models.Model):
    id = models.IntegerField("Id", primary_key=True)
    username = models.TextField("Username")

    class Meta:
        managed = False
        verbose_name = "External User Model"


# 1. mixin DfesAdminModelMixin
class ExternalUserAdmin(DfesAdminModelMixin, admin.ModelAdmin):
    list_display = (
        "id",
        "username",
    )

    # 2. and implement get_list method with returning
    # `{"total": 
    
     , "items": 
     
      }`
     
    
    def get_list(self, request, page_num, list_per_page):

        # 2.1 pull data from some service, where
        #   search = request.GET.get('q')
        #   order_by = request.GET.get('o')
        #   some_list_filter = request.GET.get('some_list_filter')
        data =  {
            'total': 1,
            'users': [
                {'id': 1, 'username': 'User1'},
            ]
        }

        # 2.2 map data to model instances
        items = [ExternalUser(**i) for i in data.get("users") or []]

        return {
            "total": data.get("total") or 0,
            "items": items,
        }

    # 3. other standart django admin customization
    def get_object(self, request, object_id, *args, **kwargs):
        # 3.1 fetch object from external service
        user = {'id': 1, 'username': 'User1'},
        # 3.2 map data to model instance
        return ExternalUser(**user)

admin.site.register(ExternalUser, ExternalUserAdmin)

License

This project is licensed under

Owner
Evgeniy Tatarkin
Evgeniy Tatarkin
A new style for Django admin

Djamin Djamin a new and clean styles for Django admin based in Google projects styles. Quick start Install djamin: pip install -e git://github.com/her

Herson Leite 236 Dec 15, 2022
Visually distinguish environments in Django Admin

django-admin-env-notice Visually distinguish environments in Django Admin. Based on great advice from post: 5 ways to make Django Admin safer by hakib

Yuri Shikanov 258 Nov 30, 2022
手部21个关键点检测,二维手势姿态,手势识别,pytorch,handpose

手部21个关键点检测,二维手势姿态,手势识别,pytorch,handpose

Eric.Lee 321 Dec 30, 2022
"Log in as user" for the Django admin.

django-loginas About "Login as user" for the Django admin. loginas supports Python 3 only, as of version 0.4. If you're on 2, use 0.3.6. Installing dj

Stavros Korokithakis 326 Dec 03, 2022
Manuskript is an open-source tool for writers.

Manuskript is an open-source tool for writers. Manuskript runs on GNU/Linux, Mac OS X, and Windows.

Olivier 1.4k Jan 07, 2023
EOD (Easy and Efficient Object Detection) is a general object detection model production framework.

EOD (Easy and Efficient Object Detection) is a general object detection model production framework.

383 Jan 07, 2023
Collection of admin fields and decorators to help to create computed or custom fields more friendly and easy way

django-admin-easy Collection of admin fields, decorators and mixin to help to create computed or custom fields more friendly and easy way Installation

Ezequiel Bertti 364 Jan 08, 2023
Jet Bridge (Universal) for Jet Admin – API-based Admin Panel Framework for your application

Jet Bridge for Jet Admin – Admin panel framework for your application Description About Jet Admin: https://about.jetadmin.io Live Demo: https://app.je

Jet Admin 1.3k Dec 27, 2022
Jazzy theme for Django

Django jazzmin (Jazzy Admin) Drop-in theme for django admin, that utilises AdminLTE 3 & Bootstrap 4 to make yo' admin look jazzy Installation pip inst

David Farrington 1.2k Jan 08, 2023
Tactical RMM is a remote monitoring & management tool for Windows computers, built with Django and Vue.

Tactical RMM is a remote monitoring & management tool for Windows computers, built with Django and Vue. It uses an agent written in golan

Dan 1.4k Dec 30, 2022
BitcartCC is a platform for merchants, users and developers which offers easy setup and use.

BitcartCC is a platform for merchants, users and developers which offers easy setup and use.

BitcartCC 270 Jan 07, 2023
A cool, modern and responsive django admin application based on bootstrap 5

django-baton A cool, modern and responsive django admin application based on bootstrap 5 Documentation: readthedocs Live Demo Now you can try django-b

Otto srl 678 Jan 01, 2023
Extendable, adaptable rewrite of django.contrib.admin

django-admin2 One of the most useful parts of django.contrib.admin is the ability to configure various views that touch and alter data. django-admin2

Jazzband 1.2k Dec 29, 2022
With Django Hijack, admins can log in and work on behalf of other users without having to know their credentials.

Django Hijack With Django Hijack, admins can log in and work on behalf of other users without having to know their credentials. Docs 3.x docs are avai

1.2k Jan 02, 2023
Material design for django administration

Django Material Administration Quick start pip install django-material-admin Add material.admin and material.admin.default to your INSTALLED_APPS sett

Anton 279 Jan 05, 2023
Real-time monitor and web admin for Celery distributed task queue

Flower Flower is a web based tool for monitoring and administrating Celery clusters. Features Real-time monitoring using Celery Events Task progress a

Mher Movsisyan 5.5k Dec 28, 2022
fastapi-admin is a fast admin dashboard based on FastAPI and TortoiseORM with tabler ui, inspired by Django admin.

fastapi-admin is a fast admin dashboard based on FastAPI and TortoiseORM with tabler ui, inspired by Django admin.

fastapi-admin 1.6k Dec 30, 2022
Python Crypto Bot

Python Crypto Bot

Michael Whittle 1.6k Jan 06, 2023
Freqtrade is a free and open source crypto trading bot written in Python

Freqtrade is a free and open source crypto trading bot written in Python. It is designed to support all major exchanges and be controlled via Telegram. It contains backtesting, plotting and money man

20.2k Jan 02, 2023
The script that able to find admin panels

admin_panel_finder The script will try to request possible admin panels by reading possible admin panels url then report as 200 YES or 404 NO usage: p

E-Pegasus 3 Mar 09, 2022