神刀安全网

Convert Django Admin to a REST API

Admino is a django package that provides a REST API for admin endpoints. It allows you to customize django admin panel.

http://admino.io

Problem?

Django admin is good solution for development tests and i/o, but django admin needs to be more customizable and extendable.

Solution:

if you want to implement a custom widget or ui for django admin, you may need a REST API to handle records.

Admino added to new api views to django admin genericly. You don’t need to change default admin files. Every API endpoint will generate your "ModelAdmin" configurations.

EXAMPLE:

Visible Books list page url:/admin/books/book/?is_visible__exact=1

Convert Django Admin to a REST API

Visible Books api url:/admin/ api /books/book//?is_visible__exact=1

Convert Django Admin to a REST API

Book detail page url:/admin/books/book/1/

Convert Django Admin to a REST API

Book detail api url:/admin/ api /books/book/1/

Convert Django Admin to a REST API

Install

settings.py

INSTALLED_APPS = [     'admino',      'django.contrib.admin',     'django.contrib.auth',     'django.contrib.contenttypes',     'django.contrib.sessions',     'django.contrib.messages',     'django.contrib.staticfiles',      'books', ] 

urls.py

from django.contrib import admin import admino  admin.site = admino.site.activated(admin.site)  urlpatterns = [     url(r'^admin/', admin.site.urls), ] 

Add custom admin Mixin class:

settings.py

ADMINO_MIXIN_CLASS = "app.module.AdminMixinClass" 

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » Convert Django Admin to a REST API

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
分享按钮