Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jiangshan00001/django_rest_admin
Adding table CRUD rest api with admin ui and without coding.
https://github.com/jiangshan00001/django_rest_admin
Last synced: about 16 hours ago
JSON representation
Adding table CRUD rest api with admin ui and without coding.
- Host: GitHub
- URL: https://github.com/jiangshan00001/django_rest_admin
- Owner: Jiangshan00001
- License: mit
- Created: 2021-10-27T13:00:01.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-26T06:49:19.000Z (over 1 year ago)
- Last Synced: 2024-10-14T13:37:22.363Z (24 days ago)
- Language: JavaScript
- Size: 535 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# django_rest_admin
Adding table CRUD rest api with admin ui and without coding.requirements:
1. django
2. djangorestframework
3. django-filterinstall:
1. pip install django_rest_admin
2. add django app:
in django project setttings.py file:
INSTALLED_APPS list, add:
```
'rest_framework',
'django_filters',
'django_rest_admin',
```3. start restapi app(the app name can change by user):
```
python manage.py startapp myRestApiApp
```
add myRestApiApp to INSTALLED_APPS:```
'myRestApiApp',
```
4 setings.py set apiapp
write below in settings.py:add this line in settings.py
```
DJANGO_REST_ADMIN_TO_APP='myRestApiApp'
```5. create admin user using command:
```python manage.py createsuperuser```6. start project using:
``` python manage.py runserver 0.0.0.0:8000 ```
7. login to /admin/
in django_rest_admin --REST接口列表 --click button --生成RestAPI
8. add urls:```
from django.urls import include
urlpatterns=[
path('api/', include ('myRestApiApp.urls')), #<<--add this line in the list]
```9. finished!
use:
1. add table in your db:
this could be down in navicat or some other db editors.
of course you could coding in django,too.
2. open admin page: http://127.0.0.1/admin/![admin-page](doc/admin_page.png)
after login, their should be a table:Table-REST-CRUD.
press Add.
the option MUST be filled:
```
A. route: the route name. eg: /Danwei
B. Table big name: the model name of a table. eg: Danwei
C. Table name: the table name. eg: danwei. ONLY needed if inspected_from_db=1
D. Inspected from db: set to 1 if table is just from db, not from django model. otherwise set to 0.
```
press Save
3. press RefreshRestAPI BUTTON in the list.
4. the django project will restart automaticly if you use debug mode.
and then the rest api is generated already.
press OpenApi button to test the api.
![admin-page](doc/rest_test_page.png)