# Duck Admin
A Django reusable app for show and operate custom forms in admin.
## Purpose
The Django Admin is great!
But it is highly depends on it's orm.
Data source not supported by Django's orm (e.g, redis, mongodb) can not show
in Django's admin site.
This app help you make your data (in redis, mongodb, file...) show in Django's Admin site.
Even you can operate with your data. (Add, Modify, Delete)
## Install
```
pip install duckadmin
```
## Usage
1. add `'duckadmin'` in `INSTALLED_APPS`
2. define your form. (you can place it in `forms.py`, `models.py`, anywhere you like)
Demonstration ( more details see [example](/example/redisapp/forms.py) )
```python
from duckadmin import DuckForm
# We define form (not model)
class MyRedisForm(DuckForm):
app_label = 'redisapp' # your app name
model_name = 'Person' # link url
verbose_name = 'Person' # name displayed in admin site
pk_name = 'id'
GENDER = (
(1, 'male'),
(2, 'female'),
)
# fields defined below will show in admin site
id = forms.IntegerField()
name = forms.CharField(max_length=32)
gender = forms.ChoiceField(choices=GENDER)
age = forms.IntegerField()
# you should implement the api below:
# `request` is django request instance
@classmethod
def get_count(cls, request):
# get count of datasets
# return integer
@classmethod
def get_data(cls, request, start, stop):
# get all data to display in change list page
# return list of data.
# data is dict format, key is fields defined above
@classmethod
def get_data_by_pk(cls, request, pk):
# change form view
@classmethod
def create_data(cls, request, data):
# create new data
@classmethod
def update_data(cls, request, data):
# update an exist data
```
3. define admin. (in file `admin.py`)
```python
from django.contrib import admin
from duckadmin import DuckAdmin
from redisapp.forms import MyRedisForm
@admin.register(MyRedisForm)
class MyRedisAdmin(DuckAdmin):
duck_form = MyRedisForm
```
After this settings. you will see `Person` in admin site.

And the change list page

You can add, modify record

A Django reusable app for show and operate custom forms in admin.
## Purpose
The Django Admin is great!
But it is highly depends on it's orm.
Data source not supported by Django's orm (e.g, redis, mongodb) can not show
in Django's admin site.
This app help you make your data (in redis, mongodb, file...) show in Django's Admin site.
Even you can operate with your data. (Add, Modify, Delete)
## Install
```
pip install duckadmin
```
## Usage
1. add `'duckadmin'` in `INSTALLED_APPS`
2. define your form. (you can place it in `forms.py`, `models.py`, anywhere you like)
Demonstration ( more details see [example](/example/redisapp/forms.py) )
```python
from duckadmin import DuckForm
# We define form (not model)
class MyRedisForm(DuckForm):
app_label = 'redisapp' # your app name
model_name = 'Person' # link url
verbose_name = 'Person' # name displayed in admin site
pk_name = 'id'
GENDER = (
(1, 'male'),
(2, 'female'),
)
# fields defined below will show in admin site
id = forms.IntegerField()
name = forms.CharField(max_length=32)
gender = forms.ChoiceField(choices=GENDER)
age = forms.IntegerField()
# you should implement the api below:
# `request` is django request instance
@classmethod
def get_count(cls, request):
# get count of datasets
# return integer
@classmethod
def get_data(cls, request, start, stop):
# get all data to display in change list page
# return list of data.
# data is dict format, key is fields defined above
@classmethod
def get_data_by_pk(cls, request, pk):
# change form view
@classmethod
def create_data(cls, request, data):
# create new data
@classmethod
def update_data(cls, request, data):
# update an exist data
```
3. define admin. (in file `admin.py`)
```python
from django.contrib import admin
from duckadmin import DuckAdmin
from redisapp.forms import MyRedisForm
@admin.register(MyRedisForm)
class MyRedisAdmin(DuckAdmin):
duck_form = MyRedisForm
```
After this settings. you will see `Person` in admin site.

And the change list page

You can add, modify record

Release files for duckadmin 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| duckadmin-0.2.0.tar.gz | 8.1 kB | Details |
Release files / duckadmin-0.2.0.tar.gz
| Download URL | duckadmin-0.2.0.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
914485f71541e915f25d298896444195b993cfb550e06307d3714565df9dc654
|
|
BLAKE2b-256 checksum How to use checksums |
d01028477a6c7b53e2d0e2d43e26c8764044b764da67a375b33e41047096bd84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |