Skip to main content

DRF-Admin

A package to generate CRUD endpoints for registered models with the Django-REST Framework.

Requirements

Installation

To install run:

pip install drf-admin

Usage

  • Import restadmin in the admin.py
  • Call restadmin.site.register(Model) Model being the model to register
  • Add rest admin to your urls.py file

Prerequisite

  • rest_framework should be properly set up to use this package hitch free

A sample of it's configuration in the settings file:

 REST_FRAMEWORK={
            'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
            'TEST_REQUEST_RENDERER_CLASSES': [
                'rest_framework.renderers.MultiPartRenderer',
                'rest_framework.renderers.JSONRenderer',
                'rest_framework.renderers.TemplateHTMLRenderer', ],
            "DEFAULT_AUTHENTICATION_CLASSES": [
                'rest_framework.authentication.SessionAuthentication',
                'rest_framework.authentication.BasicAuthentication'
            ],
            "DEFAULT_PERMISSION_CLASSES": [
                'rest_framework.permissions.AllowAny',
            ]
        }

For example:

models.py

from django.db import models

class TestModel(models.Model):
    age = models.IntegerField()

admin.py

from .models import TestModel
import restadmin

restadmin.site.register(TestModel)

urls.py

from restadmin import site
from django.urls import path




urlpatterns = [
    ...
    path('restadmin/', site.urls),
    ...
]

Customization

This package allows you to specify the following when registering your model

  • serializer: A Model Serializer Class
  • permission_classes: A list of Permission classes
  • pagination_classs: A Pagination Class

An example of how a call to the register method with all 3 would look is :

restadmin.site.register(TestModel, serializer=AdminSerializer, permission_classes=[ReadOnly], 
                        pagination_class=LargeResultsSetPagination)

Endpoint Documentation

  • This requires you to have coreapi installed

A page to document the Endpoints generated can be accessed by adding the following to your base urls file

from restadmin import site


urlpatterns = [
   ...
    path('restadmin-docs/', site.docs)
    ...
]

Using this would require you to have your default schema Class set in your REST_FRAMEWORK config in your settings.py file E.g

REST_FRAMEWORK = { 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema' }

Run your server and you can find the documentation at http://127.0.0.1:8000/restadmin-docs NOTE: The Documentation page is restricted to staff only(is_staff has to be True)

Tests

To run the tests:

From the base directory run :

python load_tests.py

Metadata

Release files for drf-admin 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for drf-admin 0.1.1
File Size Uploaded Provenance
drf-admin-0.1.1.tar.gz 3.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for drf-admin 0.1.1
File Interpreter ABI Platform
drf_admin-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.7 kB

Release files / drf-admin-0.1.1.tar.gz

Download URL drf-admin-0.1.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
129fe4cce4dc1bf28f43810bf8939403cf99a0a303a61c5ad2ddf9d4b3d452a9
BLAKE2b-256 checksum
How to use checksums
683a348a1cbf9f1ab34ab9ad9c21f6b7178971382f4e10e6756acc6367637b25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.9

Release files / drf_admin-0.1.1-py3-none-any.whl

Download URL drf_admin-0.1.1-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
209b6ca721406765c3567f7adcbe0cbc5471c665f136d8f059cf26b0a14faeb7
BLAKE2b-256 checksum
How to use checksums
f01a8b258dfa6f8ba452d07a1c3e54786b7e953eef400ccf5f921e5e63cebae8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.9

Security for drf-admin 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page