All Projects → amirasaran → django-restful-admin

amirasaran / django-restful-admin

Licence: MIT License
Django admin restful api

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to django-restful-admin

Django Antd Tyadmin
类似 xadmin 的基于Model 快速生成前后台管理增删改查,筛选,搜索的后台管理自动化工具。Antd 界面好看现代化!前后端分离!无损二次开发!由Django Restful Framework 和 Ant Design Pro V4 驱动
Stars: ✭ 171 (+235.29%)
Mutual labels:  admin, django-rest-framework, django-admin
Leaa
Leaa is a monorepo restful CMS / Admin built with Nest.js (@nestjsx/crud, node.js) and Ant Design.
Stars: ✭ 375 (+635.29%)
Mutual labels:  admin, restful
Django Cruds Adminlte
django-cruds is simple drop-in django app that creates CRUD for faster prototyping
Stars: ✭ 373 (+631.37%)
Mutual labels:  admin, django-admin
Django Admin Numeric Filter
Numeric filters for Django admin
Stars: ✭ 46 (-9.8%)
Mutual labels:  admin, django-admin
Awesome Django
Repository mirror of GitLab: https://gitlab.com/rosarior/awesome-django This repository is not monitored for issues, use original at GitLab.
Stars: ✭ 8,527 (+16619.61%)
Mutual labels:  django-rest-framework, django-admin
Blogbackendproject
Backend code for my blogs, develop with Django Rest framework.
Stars: ✭ 204 (+300%)
Mutual labels:  restful, django-rest-framework
Django Admin Bootstrap
Responsive Theme for Django Admin With Sidebar Menu
Stars: ✭ 787 (+1443.14%)
Mutual labels:  admin, django-admin
Django Practice Book
《Django企业开发实战》已出版
Stars: ✭ 251 (+392.16%)
Mutual labels:  django-rest-framework, django-admin
django-code-generator
Generate code from your Django models for faster development
Stars: ✭ 35 (-31.37%)
Mutual labels:  django-rest-framework, django-admin
Django Material Admin
Material design for django administration
Stars: ✭ 163 (+219.61%)
Mutual labels:  admin, django-admin
Awesome Django
The Best Django Resource, Awesome Django for mature packages.
Stars: ✭ 591 (+1058.82%)
Mutual labels:  django-rest-framework, django-admin
django admin chart js
An example repo showing how to add Chart.js to Django admin
Stars: ✭ 35 (-31.37%)
Mutual labels:  admin, django-admin
Rest Admin
Restful Admin Dashboard Based on Vue and Boostrap 4
Stars: ✭ 565 (+1007.84%)
Mutual labels:  admin, restful
Crudl Example Django
CRUDL with Django, DRF/Graphene and SQLite
Stars: ✭ 113 (+121.57%)
Mutual labels:  admin, django-rest-framework
django-learning-pathway
(Currently in development) Learning pathways for learning Django.
Stars: ✭ 35 (-31.37%)
Mutual labels:  django-rest-framework, django-admin
django-admin-actions
Display Django admin custom actions in changelist, changeview or per row in changelist.
Stars: ✭ 30 (-41.18%)
Mutual labels:  admin, django-admin
flask-djcelery
An example project for configuring Djcelery with Flask application and dynamically changing tasks via REST API and through django admin
Stars: ✭ 13 (-74.51%)
Mutual labels:  django-admin
yii2-rest-rbac
yii2 rbac yii2 rest RBAC Auth manager for Yii2 RESTful(YII2权限管理rbac--rest接口方式)
Stars: ✭ 79 (+54.9%)
Mutual labels:  restful
journal-manager
EteSync - server django app
Stars: ✭ 34 (-33.33%)
Mutual labels:  django-rest-framework
api-flight.com
Main API Flight Git Repository
Stars: ✭ 26 (-49.02%)
Mutual labels:  restful

Expose Django's admin as a RESTFUL service

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

Todo

  • Add some documentation
  • Add custom route Api documentation
  • Add list_display
  • Add Filter And Search
  • Add exlude
  • Add Fields
  • Example inline
  • Localization
  • Somethings that's need in future

How To Install

pip install django-restful-admin
add to INSTALED_APPS

INSTALLED_APPS = [
    ...  
   'rest_framework',   
  'django_restful_admin',    
   ...  
]  

How To use

you need only add the bellow code to admin.py in your apps

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

admin.site.register(FisrtModel)    
admin.site.register(ScoundModel)   

Then add URL to your project urls.py

from django_restful_admin import admin as api_admin 
  urlpatterns = [    
      ...   
      path('apiadmin/', api_admin.site.urls),  
  	 ...     
]  

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

enjoy!

Change Log

  • export admin in init.py
  • Add default django auth permissions support
  • Add admin.register decorator

Customization

Example

Create a new Django project

$ django-admin startproject example`
$ cd example
$ python manage.py startapp blog

Create blog app models in blog/models.py

from django.db import models

class Category(models.Model)
	title = models.CharField(  
	  max_length=255  
	)
	
class Post(models.Model):
	title = models.CharField(  
	  max_length=255  
	)
	summery = models.TextField()
	description = models.TextField()
	category = models.ForeignKey(  
		Category,  
		related_name='products',  
		on_delete=models.CASCADE  
	)

Add your blog app in INSTALLED_APPS in example/settings.py

INSTALLED_APPS = [
		# Django default apps...
		'rest_framework',
		'django_restful_admin',
		
		'blog'
]

Add admin URLs to django URLs in example/urls.py

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/', api_admin.site.urls),  # this line added
  # path('admin/', admin.site.urls),
  # your apis custom must be set here  
]

Register your model to restful admin site in blog/admin.py

from django_restful_admin import admin as api_admin  
from blog.models import *    
  
api_admin.site.register(Post) 
api_admin.site.register(Category) 

Add View and use decorators blog/admin.py

...
@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 serializers.py file in blog Open blog/serializers.py 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
@api_admin.register(Product)  
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

@api_admin.register(Product)  
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):
		pass
		## 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

Contribute

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].