Skip to main content

Python Django RestFul Admin

Project description

Expose Django's admin as a RESTFUL service

  • <input type="checkbox" checked="" disabled="" /> Support all of restful api
  • <input type="checkbox" checked="" disabled="" /> Auto generat serializers
  • <input type="checkbox" checked="" disabled="" /> Use Django Rest Framework
  • <input type="checkbox" checked="" disabled="" /> Fully customization support
  • <input type="checkbox" checked="" disabled="" /> Using Django Rest Framework ViewSet as AdminModels
  • <input type="checkbox" checked="" disabled="" /> Support default Django auth permission
  • <input type="checkbox" checked="" disabled="" /> Support Django custom model permission with simple configuration
  • <input type="checkbox" checked="" disabled="" /> Using Django Rest Framework Serializer(or ModelSerializer) as request validators
  • <input type="checkbox" checked="" disabled="" /> Support Single Serializer class to customize your detail view
  • <input type="checkbox" checked="" disabled="" /> Auto generate documentation for CURDs
  • <input type="checkbox" checked="" disabled="" /> Pagination and ability to change paginator
  • <input type="checkbox" checked="" disabled="" /> Support custom action with permission
  • <input type="checkbox" checked="" disabled="" /> Support all features in DRF
  • <input type="checkbox" checked="" disabled="" /> Support LogEntry (Log history of objects)


  • <input type="checkbox" disabled="" /> Add some documentation
  • <input type="checkbox" disabled="" /> Add custom route Api documentation
  • <input type="checkbox" disabled="" /> Add list_display
  • <input type="checkbox" disabled="" /> Add Filter And Search
  • <input type="checkbox" disabled="" /> Add exlude
  • <input type="checkbox" disabled="" /> Add Fields
  • <input type="checkbox" disabled="" /> Example inline
  • <input type="checkbox" disabled="" /> Localization
  • <input type="checkbox" disabled="" /> Somethings that's need in future

How To Install

pip install django-restful-admin


How To use

you need only add the bellow code to in your apps

from django_restful_admin import admin
from yourapp.models improt FisrtModel, ScoundModel   

Then add URL to your project

from django_restful_admin import admin as api_admin 
  urlpatterns = [    

Run the project and open URL http://your-ip:port/apiadmin/


Change Log

  • <input type="checkbox" checked="" disabled="" /> export admin in
    • <input type="checkbox" checked="" disabled="" /> Add default django auth permissions support
    • <input type="checkbox" checked="" disabled="" /> Add admin.register decorator



Create a new Django project

$ django-admin startproject example`
$ cd example
$ python startapp blog

Create blog app models in blog/

from django.db import models

class Category(models.Model)
	title = models.CharField(  

class Post(models.Model):
	title = models.CharField(  
	summery = models.TextField()
	description = models.TextField()
	category = models.ForeignKey(  

Add your blog app in INSTALLED_APPS in example/

		# Django default apps...


Add admin URLs to django URLs in example/

from django.conf.urls import url  
from django.contrib import admin  
from django_restful_admin import admin as api_admin  
from django.urls import path  

urlpatterns = [  
  path('apiadmin/',,  # this line added
  # path('admin/',,
  # your apis custom must be set here  

Register your model to restful admin site in blog/

from django_restful_admin import admin as api_admin  
from blog.models import * 

Add View and use decorators blog/

@api_admin.register(Category, Product)  
class MyCustomApiAdmin(BaseRestFulModelAdmin):  
    authentication_classes = (CustomTokenAuthentication,)
	permission_classes = [IsAuthenticated] 

Read more about authentication and permission DRF Documentation.

Customize serialization

At first, you must define your serializer class Make file in blog Open blog/ and make serializer like this:

from rest_framework import serializers
from .models import *
class ProductSerializer(serializers.ModelSerializer):
	class Meta:
		model = Product
		feilds = ('id', 'title')
class CategorySerializer(serializers.ModelSerializer):
	class Meta:
		model = Category
		fields = ('id','title)

class SingleProductSerializer(serializers.ModelSerializer):
	category = CategorySerializer(read_only=True)
	class Meta:
		model = Product
		feilds = ('id', 'title', 'summery', 'description', 'category')
from .serializers import ProductSerializer, SingleProductSerializer
class ProductApiAdmin(BaseRestFulModelAdmin):  
    serializer_class = ProductSerializer
    single_serializer_class = SingleProductSerializer

serializer_class use for serialize list of objects but single_serializer_class use for serializer view signle object, update, partial update and create.

Add a custom route with permission

class MyCustomApiAdmin(BaseRestFulModelAdmin):

	@api_admin.action(permission='product.view_product', detail=True, methods=['GET'], url_path=r'my-custom-action/(?P<another_key>[^/.]+)')  
	def my_custom_action(self, request, pk, another_key):
		## Do what you want to do
		## this action make url like this /apiadmin/blog/product/2/my-custom-action/XXX

If you want to except permission you just send permission=True, for creating custom permission you can pass closure function or lambda to permission like this permission=lambda: view, action, request, obj=None: True


If you think you can help me please let's start.

Project details

Download files

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

Files for django-restful-admin, version 1.1.3
Filename, size File type Python version Upload date Hashes
Filename, size django_restful_admin-1.1.3-py2.py3-none-any.whl (8.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-restful-admin-1.1.3.tar.gz (8.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page