django-api-admin 1.2.2__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_api_admin-1.3.0/LICENSE-DJANGO +27 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/PKG-INFO +118 -70
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/README.md +110 -40
- django_api_admin-1.3.0/assets/images/logo.png +0 -0
- django_api_admin-1.3.0/assets/images/screenshot.png +0 -0
- django_api_admin-1.3.0/django_api_admin/API_DOCS.md +22 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/__init__.py +13 -3
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/actions.py +8 -14
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/admin_views/admin_site_views/app_index.py +21 -24
- django_api_admin-1.3.0/django_api_admin/admin_views/admin_site_views/app_list.py +31 -0
- django_api_admin-1.3.0/django_api_admin/admin_views/admin_site_views/autocomplete.py +189 -0
- django_api_admin-1.3.0/django_api_admin/admin_views/admin_site_views/get_authenticated_user.py +7 -0
- django_api_admin-1.3.0/django_api_admin/admin_views/admin_site_views/get_permissions.py +59 -0
- django_api_admin-1.3.0/django_api_admin/admin_views/admin_site_views/history.py +116 -0
- django_api_admin-1.2.2/django_api_admin/admin_views/model_admin_views/__init__.py → django_api_admin-1.3.0/django_api_admin/admin_views/admin_site_views/language_catalog.py +0 -0
- django_api_admin-1.3.0/django_api_admin/admin_views/admin_site_views/site_context.py +66 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/admin_views/admin_site_views/view_on_site.py +38 -29
- {django_api_admin-1.2.2/django_api_admin/admins → django_api_admin-1.3.0/django_api_admin/admin_views/model_admin_views}/__init__.py +0 -0
- django_api_admin-1.3.0/django_api_admin/admin_views/model_admin_views/add.py +95 -0
- django_api_admin-1.3.0/django_api_admin/admin_views/model_admin_views/change.py +179 -0
- django_api_admin-1.3.0/django_api_admin/admin_views/model_admin_views/changelist.py +266 -0
- django_api_admin-1.3.0/django_api_admin/admin_views/model_admin_views/delete.py +82 -0
- django_api_admin-1.3.0/django_api_admin/admin_views/model_admin_views/detail.py +70 -0
- django_api_admin-1.3.0/django_api_admin/admins/base_admin.py +502 -0
- django_api_admin-1.3.0/django_api_admin/admins/inline_admin.py +117 -0
- django_api_admin-1.3.0/django_api_admin/admins/model_admin.py +945 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/apps.py +4 -2
- django_api_admin-1.3.0/django_api_admin/bulk.py +295 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/changelist.py +220 -121
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/checks.py +193 -310
- django_api_admin-1.3.0/django_api_admin/constants.py +86 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/decorators.py +17 -7
- django_api_admin-1.3.0/django_api_admin/exceptions.py +51 -0
- django_api_admin-1.3.0/django_api_admin/extensions.py +27 -0
- django_api_admin-1.3.0/django_api_admin/fields.py +27 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/filters.py +233 -150
- django_api_admin-1.3.0/django_api_admin/hooks.py +473 -0
- django_api_admin-1.3.0/django_api_admin/locale/ar/LC_MESSAGES/django.po +671 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/models.py +46 -60
- django_api_admin-1.3.0/django_api_admin/openapi.py +508 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/pagination.py +5 -5
- django_api_admin-1.3.0/django_api_admin/serializers.py +641 -0
- django_api_admin-1.3.0/django_api_admin/sites.py +530 -0
- {django_api_admin-1.2.2/django_api_admin/migrations → django_api_admin-1.3.0/django_api_admin/utils}/__init__.py +0 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/utils/_get_non_gfk_field.py +8 -6
- django_api_admin-1.3.0/django_api_admin/utils/build_q_object_from_lookup_parameters.py +11 -0
- django_api_admin-1.3.0/django_api_admin/utils/construct_change_message.py +64 -0
- django_api_admin-1.3.0/django_api_admin/utils/flatten.py +19 -0
- django_api_admin-1.3.0/django_api_admin/utils/flatten_fieldsets.py +16 -0
- django_api_admin-1.3.0/django_api_admin/utils/get_changed_data.py +53 -0
- django_api_admin-1.3.0/django_api_admin/utils/get_content_type_for_model.py +14 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/utils/get_deleted_objects.py +14 -30
- django_api_admin-1.3.0/django_api_admin/utils/get_field_attributes.py +58 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/utils/get_fields_from_path.py +8 -1
- django_api_admin-1.3.0/django_api_admin/utils/get_form_fields.py +44 -0
- django_api_admin-1.3.0/django_api_admin/utils/get_last_value_from_parameters.py +3 -0
- django_api_admin-1.3.0/django_api_admin/utils/get_model_from_relation.py +15 -0
- django_api_admin-1.3.0/django_api_admin/utils/get_related_name.py +7 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/utils/label_for_field.py +8 -5
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/utils/lookup_field.py +7 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/utils/lookup_spawns_duplicates.py +8 -1
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/utils/model_format_dict.py +8 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/utils/model_ngettext.py +7 -0
- django_api_admin-1.3.0/django_api_admin/utils/model_serializer_factory.py +84 -0
- django_api_admin-1.3.0/django_api_admin/utils/modelserializer_defines_fields.py +4 -0
- django_api_admin-1.3.0/django_api_admin/utils/module_loading.py +44 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/utils/nested_objects.py +8 -3
- django_api_admin-1.3.0/django_api_admin/utils/prepare_lookup_value.py +21 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/utils/quote.py +8 -2
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/utils/remove_field.py +1 -4
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/utils/reverse_field_path.py +8 -1
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/utils/url_params_from_lookup_dict.py +8 -0
- django_api_admin-1.3.0/pyproject.toml +62 -0
- django_api_admin-1.3.0/tests/mock_app/actions.py +23 -0
- django_api_admin-1.3.0/tests/mock_app/admin.py +128 -0
- django_api_admin-1.3.0/tests/mock_app/fields.py +17 -0
- django_api_admin-1.3.0/tests/mock_app/models.py +147 -0
- django_api_admin-1.3.0/tests/mock_app/serializers.py +25 -0
- django_api_admin-1.3.0/tests/mock_app/tests.py +846 -0
- django_api_admin-1.3.0/tests/mock_app/urls.py +9 -0
- django_api_admin-1.3.0/tests/mock_app/views.py +9 -0
- django_api_admin-1.3.0/tests/runtests.py +452 -0
- django_api_admin-1.3.0/tests/test_sqlite.py +26 -0
- django_api_admin-1.3.0/tests/urls.py +6 -0
- django_api_admin-1.2.2/django_api_admin/admin_views/admin_site_views/admin_api_root.py +0 -23
- django_api_admin-1.2.2/django_api_admin/admin_views/admin_site_views/admin_log.py +0 -83
- django_api_admin-1.2.2/django_api_admin/admin_views/admin_site_views/autocomplete.py +0 -155
- django_api_admin-1.2.2/django_api_admin/admin_views/admin_site_views/index.py +0 -38
- django_api_admin-1.2.2/django_api_admin/admin_views/admin_site_views/language_catalog.py +0 -98
- django_api_admin-1.2.2/django_api_admin/admin_views/admin_site_views/obtain_token.py +0 -95
- django_api_admin-1.2.2/django_api_admin/admin_views/admin_site_views/password_change.py +0 -77
- django_api_admin-1.2.2/django_api_admin/admin_views/admin_site_views/site_context.py +0 -29
- django_api_admin-1.2.2/django_api_admin/admin_views/admin_site_views/token_refresh.py +0 -7
- django_api_admin-1.2.2/django_api_admin/admin_views/admin_site_views/user_information.py +0 -40
- django_api_admin-1.2.2/django_api_admin/admin_views/model_admin_views/add.py +0 -104
- django_api_admin-1.2.2/django_api_admin/admin_views/model_admin_views/change.py +0 -208
- django_api_admin-1.2.2/django_api_admin/admin_views/model_admin_views/changelist.py +0 -176
- django_api_admin-1.2.2/django_api_admin/admin_views/model_admin_views/delete.py +0 -104
- django_api_admin-1.2.2/django_api_admin/admin_views/model_admin_views/detail.py +0 -60
- django_api_admin-1.2.2/django_api_admin/admin_views/model_admin_views/handle_action.py +0 -105
- django_api_admin-1.2.2/django_api_admin/admin_views/model_admin_views/history.py +0 -52
- django_api_admin-1.2.2/django_api_admin/admin_views/model_admin_views/list.py +0 -36
- django_api_admin-1.2.2/django_api_admin/admins/base_admin.py +0 -284
- django_api_admin-1.2.2/django_api_admin/admins/inline_admin.py +0 -87
- django_api_admin-1.2.2/django_api_admin/admins/model_admin.py +0 -593
- django_api_admin-1.2.2/django_api_admin/constants/field_attributes.py +0 -82
- django_api_admin-1.2.2/django_api_admin/constants/vars.py +0 -12
- django_api_admin-1.2.2/django_api_admin/declarations/functions.py +0 -305
- django_api_admin-1.2.2/django_api_admin/exceptions.py +0 -31
- django_api_admin-1.2.2/django_api_admin/hooks.py +0 -67
- django_api_admin-1.2.2/django_api_admin/openapi.py +0 -303
- django_api_admin-1.2.2/django_api_admin/options.py +0 -287
- django_api_admin-1.2.2/django_api_admin/permissions.py +0 -10
- django_api_admin-1.2.2/django_api_admin/serializers.py +0 -399
- django_api_admin-1.2.2/django_api_admin/sites.py +0 -510
- django_api_admin-1.2.2/django_api_admin/utils/diff_helper.py +0 -46
- django_api_admin-1.2.2/django_api_admin/utils/flatten.py +0 -11
- django_api_admin-1.2.2/django_api_admin/utils/force_login.py +0 -14
- django_api_admin-1.2.2/django_api_admin/utils/get_content_type_for_model.py +0 -6
- django_api_admin-1.2.2/django_api_admin/utils/get_field_attributes.py +0 -54
- django_api_admin-1.2.2/django_api_admin/utils/get_form_config.py +0 -13
- django_api_admin-1.2.2/django_api_admin/utils/get_form_fields.py +0 -46
- django_api_admin-1.2.2/django_api_admin/utils/get_inline_by_field_name.py +0 -12
- django_api_admin-1.2.2/django_api_admin/utils/get_inlines.py +0 -51
- django_api_admin-1.2.2/django_api_admin/utils/get_model_from_relation.py +0 -8
- django_api_admin-1.2.2/django_api_admin/utils/get_related_name.py +0 -10
- django_api_admin-1.2.2/django_api_admin/utils/prepare_lookup_value.py +0 -11
- django_api_admin-1.2.2/django_api_admin/utils/validate_bulk_edits.py +0 -105
- django_api_admin-1.2.2/django_api_admin/utils/validate_inline_field_names.py +0 -25
- django_api_admin-1.2.2/django_api_admin/views/__init__.py +0 -0
- django_api_admin-1.2.2/django_api_admin/views/admin_views.py +0 -677
- django_api_admin-1.2.2/django_api_admin/views/site_views.py +0 -251
- django_api_admin-1.2.2/django_api_admin.egg-info/PKG-INFO +0 -383
- django_api_admin-1.2.2/django_api_admin.egg-info/SOURCES.txt +0 -88
- django_api_admin-1.2.2/django_api_admin.egg-info/dependency_links.txt +0 -1
- django_api_admin-1.2.2/django_api_admin.egg-info/requires.txt +0 -7
- django_api_admin-1.2.2/django_api_admin.egg-info/top_level.txt +0 -2
- django_api_admin-1.2.2/pyproject.toml +0 -44
- django_api_admin-1.2.2/setup.cfg +0 -4
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/LICENSE +0 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/admin_views/admin_site_views/__init__.py +0 -0
- {django_api_admin-1.2.2/django_api_admin/constants → django_api_admin-1.3.0/django_api_admin/admins}/__init__.py +0 -0
- {django_api_admin-1.2.2 → django_api_admin-1.3.0}/django_api_admin/migrations/0001_initial.py +0 -0
- {django_api_admin-1.2.2/django_api_admin/declarations → django_api_admin-1.3.0/django_api_admin/migrations}/__init__.py +0 -0
- {django_api_admin-1.2.2/django_api_admin/utils → django_api_admin-1.3.0/tests/mock_app}/__init__.py +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Copyright (c) Django Software Foundation and individual contributors.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
5
|
+
are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
this list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
notice, this list of conditions and the following disclaimer in the
|
|
12
|
+
documentation and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
3. Neither the name of Django nor the names of its contributors may be used
|
|
15
|
+
to endorse or promote products derived from this software without
|
|
16
|
+
specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
19
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
20
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
22
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
23
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
24
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
25
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
27
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,42 +1,20 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: django-api-admin
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: A RESTful API implementation of django.contrib.admin, designed for writing custom frontends.
|
|
5
|
+
Author: Muhammad Salah
|
|
5
6
|
Author-email: Muhammad Salah <msbizzacc0unt@outlook.com>
|
|
6
|
-
License:
|
|
7
|
-
|
|
8
|
-
Copyright (c) 2021 Muhammad Salah
|
|
9
|
-
|
|
10
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
-
in the Software without restriction, including without limitation the rights
|
|
13
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
-
furnished to do so, subject to the following conditions:
|
|
16
|
-
|
|
17
|
-
The above copyright notice and this permission notice shall be included in all
|
|
18
|
-
copies or substantial portions of the Software.
|
|
19
|
-
|
|
20
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
-
SOFTWARE.
|
|
27
|
-
|
|
28
|
-
Project-URL: Github, https://github.com/demon-bixia/django-api-admin
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
License-File: LICENSE-DJANGO
|
|
29
9
|
Classifier: Programming Language :: Python :: 3
|
|
30
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
31
11
|
Classifier: Operating System :: OS Independent
|
|
32
|
-
Description-Content-Type: text/markdown
|
|
33
|
-
License-File: LICENSE
|
|
34
12
|
Requires-Dist: django
|
|
35
13
|
Requires-Dist: djangorestframework
|
|
36
|
-
Requires-Dist: djangorestframework-simplejwt
|
|
37
14
|
Requires-Dist: drf-spectacular
|
|
38
|
-
|
|
39
|
-
|
|
15
|
+
Requires-Python: >=3.12
|
|
16
|
+
Project-URL: Github, https://github.com/demon-bixia/django-api-admin
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
40
18
|
|
|
41
19
|
<a id="readme-top"></a>
|
|
42
20
|
|
|
@@ -59,7 +37,7 @@ Requires-Dist: django-cors-headers; extra == "dev"
|
|
|
59
37
|
<img src="assets/images/logo.png" alt="Logo" width="300" height="300">
|
|
60
38
|
</a>
|
|
61
39
|
|
|
62
|
-
<
|
|
40
|
+
<h1 align="center">Django API Admin</h1>
|
|
63
41
|
|
|
64
42
|
<p align="center">
|
|
65
43
|
A RESTful API implementation of django.contrib.admin, designed for writing custom frontends.
|
|
@@ -92,6 +70,8 @@ Requires-Dist: django-cors-headers; extra == "dev"
|
|
|
92
70
|
<ul>
|
|
93
71
|
<li><a href="#prerequisites">Prerequisites</a></li>
|
|
94
72
|
<li><a href="#installation">Installation</a></li>
|
|
73
|
+
<li><a href="#cors">CORS Configuration</a></li>
|
|
74
|
+
<li><a href="#authentication">Authentication</a></li>
|
|
95
75
|
</ul>
|
|
96
76
|
</li>
|
|
97
77
|
<li><a href="#usage">Usage</a></li>
|
|
@@ -108,14 +88,14 @@ Requires-Dist: django-cors-headers; extra == "dev"
|
|
|
108
88
|
<!-- ABOUT THE PROJECT -->
|
|
109
89
|
## About The Project
|
|
110
90
|
|
|
111
|
-
[![Product Name Screen Shot][product-screenshot]](https://
|
|
91
|
+
[![Product Name Screen Shot][product-screenshot]](https://github.com/demon-bixia/django-api-admin)
|
|
112
92
|
|
|
113
|
-
|
|
93
|
+
Django API Admin is a RESTful API implementation of the `django.contrib.admin` application, designed to make it easy to create custom frontends. This project aims to provide developers with a flexible API that mirrors the functionality of Django's built-in admin interface, allowing for seamless integration with modern web client interfaces.
|
|
114
94
|
|
|
115
95
|
### Key Features:
|
|
116
96
|
- **RESTful API**: Offers a comprehensive API for managing Django models, enabling developers to build custom administrative interfaces.
|
|
117
97
|
- **Custom Frontends**: Designed to support the development of tailored frontends that meet specific project requirements.
|
|
118
|
-
- **Extensible and Modular**: Build with the same django.contrib.admin API, allowing for easy customization and integration with existing Django projects.
|
|
98
|
+
- **Extensible and Modular**: Build with the same `django.contrib.admin` API, allowing for easy customization and integration with existing Django projects.
|
|
119
99
|
|
|
120
100
|
The project is continuously evolving, with new features and improvements being added regularly. Contributions from the community are highly encouraged to help expand and enhance the capabilities of this tool.
|
|
121
101
|
|
|
@@ -133,6 +113,8 @@ This section should list any major frameworks/libraries used to bootstrap your p
|
|
|
133
113
|
|
|
134
114
|
* [![Django][Django]][Django-url]
|
|
135
115
|
* [![DRF][Django REST framework]][DRF-url]
|
|
116
|
+
* [![DRFSPD][DRF Spectacular]][DRFSPD-url]
|
|
117
|
+
|
|
136
118
|
|
|
137
119
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
138
120
|
|
|
@@ -147,13 +129,9 @@ To set up the project locally, follow these steps:
|
|
|
147
129
|
|
|
148
130
|
Before you begin, ensure you have met the following requirements:
|
|
149
131
|
|
|
150
|
-
- **Python 3.
|
|
151
|
-
|
|
152
|
-
- **pip**: Ensure you have pip installed for managing Python packages. It usually comes with Python installations.
|
|
132
|
+
- **Python 3.12+**: Make sure Python is installed on your machine. You can download it from [python.org](https://www.python.org/downloads/).
|
|
153
133
|
|
|
154
|
-
- **
|
|
155
|
-
|
|
156
|
-
- **rest_framework**
|
|
134
|
+
- **Django REST framework**
|
|
157
135
|
```sh
|
|
158
136
|
pip install djangorestframework
|
|
159
137
|
```
|
|
@@ -161,18 +139,11 @@ Before you begin, ensure you have met the following requirements:
|
|
|
161
139
|
```sh
|
|
162
140
|
pip install drf-spectacular
|
|
163
141
|
```
|
|
164
|
-
|
|
165
|
-
```sh
|
|
166
|
-
pip install djangorestframework-simplejwt
|
|
167
|
-
```
|
|
168
|
-
- **django-cors-headers**
|
|
169
|
-
```sh
|
|
170
|
-
pip install django-cors-headers
|
|
171
|
-
```
|
|
142
|
+
|
|
172
143
|
|
|
173
144
|
### Installation
|
|
174
145
|
|
|
175
|
-
This
|
|
146
|
+
This section will walk you through the steps to install `django-api-admin` in your Django project. Follow these instructions to get started.
|
|
176
147
|
|
|
177
148
|
1. **Install the Package**
|
|
178
149
|
```sh
|
|
@@ -195,16 +166,7 @@ This guide will walk you through the steps to integrate `django-api-admin` into
|
|
|
195
166
|
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
|
|
196
167
|
}
|
|
197
168
|
```
|
|
198
|
-
4. Add the
|
|
199
|
-
```py
|
|
200
|
-
# settings.py
|
|
201
|
-
CORS_ORIGIN_WHITELIST = (
|
|
202
|
-
'http://localhost', # jest-dom test server
|
|
203
|
-
'http://localhost:3000', # react developement server
|
|
204
|
-
)
|
|
205
|
-
CORS_ALLOW_CREDENTIALS = True
|
|
206
|
-
```
|
|
207
|
-
5. **Add the modify_schema hook** used to tag paths in the openapi schema
|
|
169
|
+
4. **Add the modify_schema hook** to improve the auto generated openAPI schema
|
|
208
170
|
```py
|
|
209
171
|
# settings.py
|
|
210
172
|
SPECTACULAR_SETTINGS = {
|
|
@@ -217,6 +179,96 @@ This guide will walk you through the steps to integrate `django-api-admin` into
|
|
|
217
179
|
|
|
218
180
|
Thats it you are now ready to register your models and implement your django admin frontend!
|
|
219
181
|
|
|
182
|
+
### CORS Configuration
|
|
183
|
+
|
|
184
|
+
If you plan to build a custom frontend in React.js or Vue.js then you might want to consider adding CORS configuration to your Django project. This will allow your frontend to make requests to your Django backend.
|
|
185
|
+
|
|
186
|
+
1. Install **django-cors-headers** package
|
|
187
|
+
```sh
|
|
188
|
+
pip install django-cors-headers
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
2. Add `corsheaders` to `INSTALLED_APPS` in your Django project's settings.py file (the order doesn't matter):
|
|
192
|
+
```py
|
|
193
|
+
# settings.py
|
|
194
|
+
INSTALLED_APPS = [
|
|
195
|
+
'corsheaders',
|
|
196
|
+
# ...
|
|
197
|
+
]
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
3. Add the urls of your client side applications to the `CORS_ORIGIN_WHITELIST`
|
|
201
|
+
```py
|
|
202
|
+
# settings.py
|
|
203
|
+
CORS_ORIGIN_WHITELIST = (
|
|
204
|
+
'http://localhost', # jest-dom test server
|
|
205
|
+
'http://localhost:3000', # react development server
|
|
206
|
+
)
|
|
207
|
+
CORS_ALLOW_CREDENTIALS = True
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Your client side application should now be able to make requests to your django backend!
|
|
211
|
+
|
|
212
|
+
### Authentication
|
|
213
|
+
|
|
214
|
+
Unlike `django.contrib.admin` this package doesn't include it's own authentication functionality. You will need implement authentication on your own, however the `django-api-admin` makes it very easy to add support for authentication frameworks that support `rest_framework`. This is how you can add `django-allauth` for instance:
|
|
215
|
+
|
|
216
|
+
1. Install `django-allauth`
|
|
217
|
+
|
|
218
|
+
```sh
|
|
219
|
+
pip install django-allauth
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
2. Configure `django-allauth` settings for your project
|
|
223
|
+
|
|
224
|
+
```py
|
|
225
|
+
# settings.py
|
|
226
|
+
|
|
227
|
+
INSTALLED_APPS = [
|
|
228
|
+
# ...
|
|
229
|
+
'allauth',
|
|
230
|
+
]
|
|
231
|
+
|
|
232
|
+
MIDDLEWARE = [
|
|
233
|
+
# ...
|
|
234
|
+
'allauth.account.middleware.AccountMiddleware',
|
|
235
|
+
# ...
|
|
236
|
+
]
|
|
237
|
+
|
|
238
|
+
AUTHENTICATION_BACKENDS = [
|
|
239
|
+
'django.contrib.auth.backends.ModelBackend',
|
|
240
|
+
'allauth.account.auth_backends.AuthenticationBackend',
|
|
241
|
+
]
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
3. Add the `authentication_classes` to an `APIAdminSite` subclass.
|
|
245
|
+
|
|
246
|
+
```py
|
|
247
|
+
from django_api_admin import APIAdminSite
|
|
248
|
+
|
|
249
|
+
class AdminSite(APIAdminSite):
|
|
250
|
+
def get_authentication_classes(self):
|
|
251
|
+
from allauth.headless.contrib.rest_framework.authentication import XSessionTokenAuthentication
|
|
252
|
+
|
|
253
|
+
return [XSessionTokenAuthentication, authentication.SessionAuthentication]
|
|
254
|
+
|
|
255
|
+
site = AdminSite()
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
4. include the `django-allauth` headless urls in your `urls.py` file.
|
|
260
|
+
|
|
261
|
+
```python
|
|
262
|
+
# urls.py
|
|
263
|
+
urlpatterns = [
|
|
264
|
+
# ...
|
|
265
|
+
path("_allauth/", include("allauth.headless.urls")),
|
|
266
|
+
]
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Now, `django-api-admin` will use the provided `authentication_classes` for authenticating users.
|
|
270
|
+
|
|
271
|
+
|
|
220
272
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
221
273
|
|
|
222
274
|
|
|
@@ -280,11 +332,8 @@ This section provides a simple example on how to use django-api-admin. If you're
|
|
|
280
332
|
- [x] Rewrite django.contrib.admin as an API
|
|
281
333
|
- [x] Add support for Bulk Actions
|
|
282
334
|
- [x] Add OpenAPI documentation
|
|
283
|
-
- [ ] Add
|
|
284
|
-
- [ ]
|
|
285
|
-
- [ ] Multi-language Support
|
|
286
|
-
- [ ] Arabic
|
|
287
|
-
- [ ] Spanish
|
|
335
|
+
- [ ] Add support for charts
|
|
336
|
+
- [ ] Add support for global full-text search
|
|
288
337
|
|
|
289
338
|
See the [open issues](https://github.com/demon-bixia/django-api-admin/issues) for a full list of proposed features (and known issues).
|
|
290
339
|
|
|
@@ -328,9 +377,9 @@ Distributed under the MIT License. See the `LICENSE` file for more information.
|
|
|
328
377
|
<!-- CONTACT -->
|
|
329
378
|
## Contact
|
|
330
379
|
|
|
331
|
-
Muhammad Salah - [@
|
|
380
|
+
Muhammad Salah - [@daemobixia](https://t.me/demonbixia) - [msbizzaccount@gmail.com](mailto:[EMAIL_ADDRESS])
|
|
332
381
|
|
|
333
|
-
Project Link: [https://github.com/demon-bixia/django-api-admin](https://github.com/
|
|
382
|
+
Project Link: [https://github.com/demon-bixia/django-api-admin](https://github.com/daemon-bixia/django-api-admin)
|
|
334
383
|
|
|
335
384
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
336
385
|
|
|
@@ -343,12 +392,8 @@ This section is dedicated to recognizing the valuable resources and contribution
|
|
|
343
392
|
|
|
344
393
|
* [Django Web Framework](https://www.djangoproject.com/)
|
|
345
394
|
* [Django Rest Framework](https://www.django-rest-framework.org/)
|
|
346
|
-
* [Simple JWT](https://github.com/jazzband/djangorestframework-simplejwt/tree/master)
|
|
347
|
-
* [Django Cors Headers](https://github.com/adamchainz/django-cors-headers)
|
|
348
395
|
* [DRF Spectacular](https://github.com/tfranzel/drf-spectacular)
|
|
349
|
-
* [Django Restful Admin](https://github.com/amirasaran/django-restful-admin)
|
|
350
396
|
* [Best README Template](https://github.com/othneildrew/Best-README-Template)
|
|
351
|
-
* [QODO AI](https://www.qodo.ai/)
|
|
352
397
|
|
|
353
398
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
354
399
|
|
|
@@ -380,4 +425,7 @@ This section is dedicated to recognizing the valuable resources and contribution
|
|
|
380
425
|
[DRF-url]: https://www.django-rest-framework.org/
|
|
381
426
|
[Django REST framework]: https://img.shields.io/badge/django--rest--framework-3.12.4-green?style=for-the-badge&labelColor=333333&logo=django&logoColor=white&color=green
|
|
382
427
|
|
|
428
|
+
[DRFSPD-url]: https://drf-spectacular.readthedocs.io/en/latest/
|
|
429
|
+
[DRF Spectacular]: https://img.shields.io/badge/drf-spectacular-orange?style=for-the-badge&labelColor=333333&logo=django&logoColor=white&color=green
|
|
430
|
+
|
|
383
431
|
[product-screenshot]: assets/images/screenshot.png
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<img src="assets/images/logo.png" alt="Logo" width="300" height="300">
|
|
20
20
|
</a>
|
|
21
21
|
|
|
22
|
-
<
|
|
22
|
+
<h1 align="center">Django API Admin</h1>
|
|
23
23
|
|
|
24
24
|
<p align="center">
|
|
25
25
|
A RESTful API implementation of django.contrib.admin, designed for writing custom frontends.
|
|
@@ -52,6 +52,8 @@
|
|
|
52
52
|
<ul>
|
|
53
53
|
<li><a href="#prerequisites">Prerequisites</a></li>
|
|
54
54
|
<li><a href="#installation">Installation</a></li>
|
|
55
|
+
<li><a href="#cors">CORS Configuration</a></li>
|
|
56
|
+
<li><a href="#authentication">Authentication</a></li>
|
|
55
57
|
</ul>
|
|
56
58
|
</li>
|
|
57
59
|
<li><a href="#usage">Usage</a></li>
|
|
@@ -68,14 +70,14 @@
|
|
|
68
70
|
<!-- ABOUT THE PROJECT -->
|
|
69
71
|
## About The Project
|
|
70
72
|
|
|
71
|
-
[![Product Name Screen Shot][product-screenshot]](https://
|
|
73
|
+
[![Product Name Screen Shot][product-screenshot]](https://github.com/demon-bixia/django-api-admin)
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
Django API Admin is a RESTful API implementation of the `django.contrib.admin` application, designed to make it easy to create custom frontends. This project aims to provide developers with a flexible API that mirrors the functionality of Django's built-in admin interface, allowing for seamless integration with modern web client interfaces.
|
|
74
76
|
|
|
75
77
|
### Key Features:
|
|
76
78
|
- **RESTful API**: Offers a comprehensive API for managing Django models, enabling developers to build custom administrative interfaces.
|
|
77
79
|
- **Custom Frontends**: Designed to support the development of tailored frontends that meet specific project requirements.
|
|
78
|
-
- **Extensible and Modular**: Build with the same django.contrib.admin API, allowing for easy customization and integration with existing Django projects.
|
|
80
|
+
- **Extensible and Modular**: Build with the same `django.contrib.admin` API, allowing for easy customization and integration with existing Django projects.
|
|
79
81
|
|
|
80
82
|
The project is continuously evolving, with new features and improvements being added regularly. Contributions from the community are highly encouraged to help expand and enhance the capabilities of this tool.
|
|
81
83
|
|
|
@@ -93,6 +95,8 @@ This section should list any major frameworks/libraries used to bootstrap your p
|
|
|
93
95
|
|
|
94
96
|
* [![Django][Django]][Django-url]
|
|
95
97
|
* [![DRF][Django REST framework]][DRF-url]
|
|
98
|
+
* [![DRFSPD][DRF Spectacular]][DRFSPD-url]
|
|
99
|
+
|
|
96
100
|
|
|
97
101
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
98
102
|
|
|
@@ -107,13 +111,9 @@ To set up the project locally, follow these steps:
|
|
|
107
111
|
|
|
108
112
|
Before you begin, ensure you have met the following requirements:
|
|
109
113
|
|
|
110
|
-
- **Python 3.
|
|
111
|
-
|
|
112
|
-
- **pip**: Ensure you have pip installed for managing Python packages. It usually comes with Python installations.
|
|
114
|
+
- **Python 3.12+**: Make sure Python is installed on your machine. You can download it from [python.org](https://www.python.org/downloads/).
|
|
113
115
|
|
|
114
|
-
- **
|
|
115
|
-
|
|
116
|
-
- **rest_framework**
|
|
116
|
+
- **Django REST framework**
|
|
117
117
|
```sh
|
|
118
118
|
pip install djangorestframework
|
|
119
119
|
```
|
|
@@ -121,18 +121,11 @@ Before you begin, ensure you have met the following requirements:
|
|
|
121
121
|
```sh
|
|
122
122
|
pip install drf-spectacular
|
|
123
123
|
```
|
|
124
|
-
|
|
125
|
-
```sh
|
|
126
|
-
pip install djangorestframework-simplejwt
|
|
127
|
-
```
|
|
128
|
-
- **django-cors-headers**
|
|
129
|
-
```sh
|
|
130
|
-
pip install django-cors-headers
|
|
131
|
-
```
|
|
124
|
+
|
|
132
125
|
|
|
133
126
|
### Installation
|
|
134
127
|
|
|
135
|
-
This
|
|
128
|
+
This section will walk you through the steps to install `django-api-admin` in your Django project. Follow these instructions to get started.
|
|
136
129
|
|
|
137
130
|
1. **Install the Package**
|
|
138
131
|
```sh
|
|
@@ -155,16 +148,7 @@ This guide will walk you through the steps to integrate `django-api-admin` into
|
|
|
155
148
|
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
|
|
156
149
|
}
|
|
157
150
|
```
|
|
158
|
-
4. Add the
|
|
159
|
-
```py
|
|
160
|
-
# settings.py
|
|
161
|
-
CORS_ORIGIN_WHITELIST = (
|
|
162
|
-
'http://localhost', # jest-dom test server
|
|
163
|
-
'http://localhost:3000', # react developement server
|
|
164
|
-
)
|
|
165
|
-
CORS_ALLOW_CREDENTIALS = True
|
|
166
|
-
```
|
|
167
|
-
5. **Add the modify_schema hook** used to tag paths in the openapi schema
|
|
151
|
+
4. **Add the modify_schema hook** to improve the auto generated openAPI schema
|
|
168
152
|
```py
|
|
169
153
|
# settings.py
|
|
170
154
|
SPECTACULAR_SETTINGS = {
|
|
@@ -177,6 +161,96 @@ This guide will walk you through the steps to integrate `django-api-admin` into
|
|
|
177
161
|
|
|
178
162
|
Thats it you are now ready to register your models and implement your django admin frontend!
|
|
179
163
|
|
|
164
|
+
### CORS Configuration
|
|
165
|
+
|
|
166
|
+
If you plan to build a custom frontend in React.js or Vue.js then you might want to consider adding CORS configuration to your Django project. This will allow your frontend to make requests to your Django backend.
|
|
167
|
+
|
|
168
|
+
1. Install **django-cors-headers** package
|
|
169
|
+
```sh
|
|
170
|
+
pip install django-cors-headers
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
2. Add `corsheaders` to `INSTALLED_APPS` in your Django project's settings.py file (the order doesn't matter):
|
|
174
|
+
```py
|
|
175
|
+
# settings.py
|
|
176
|
+
INSTALLED_APPS = [
|
|
177
|
+
'corsheaders',
|
|
178
|
+
# ...
|
|
179
|
+
]
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
3. Add the urls of your client side applications to the `CORS_ORIGIN_WHITELIST`
|
|
183
|
+
```py
|
|
184
|
+
# settings.py
|
|
185
|
+
CORS_ORIGIN_WHITELIST = (
|
|
186
|
+
'http://localhost', # jest-dom test server
|
|
187
|
+
'http://localhost:3000', # react development server
|
|
188
|
+
)
|
|
189
|
+
CORS_ALLOW_CREDENTIALS = True
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Your client side application should now be able to make requests to your django backend!
|
|
193
|
+
|
|
194
|
+
### Authentication
|
|
195
|
+
|
|
196
|
+
Unlike `django.contrib.admin` this package doesn't include it's own authentication functionality. You will need implement authentication on your own, however the `django-api-admin` makes it very easy to add support for authentication frameworks that support `rest_framework`. This is how you can add `django-allauth` for instance:
|
|
197
|
+
|
|
198
|
+
1. Install `django-allauth`
|
|
199
|
+
|
|
200
|
+
```sh
|
|
201
|
+
pip install django-allauth
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
2. Configure `django-allauth` settings for your project
|
|
205
|
+
|
|
206
|
+
```py
|
|
207
|
+
# settings.py
|
|
208
|
+
|
|
209
|
+
INSTALLED_APPS = [
|
|
210
|
+
# ...
|
|
211
|
+
'allauth',
|
|
212
|
+
]
|
|
213
|
+
|
|
214
|
+
MIDDLEWARE = [
|
|
215
|
+
# ...
|
|
216
|
+
'allauth.account.middleware.AccountMiddleware',
|
|
217
|
+
# ...
|
|
218
|
+
]
|
|
219
|
+
|
|
220
|
+
AUTHENTICATION_BACKENDS = [
|
|
221
|
+
'django.contrib.auth.backends.ModelBackend',
|
|
222
|
+
'allauth.account.auth_backends.AuthenticationBackend',
|
|
223
|
+
]
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
3. Add the `authentication_classes` to an `APIAdminSite` subclass.
|
|
227
|
+
|
|
228
|
+
```py
|
|
229
|
+
from django_api_admin import APIAdminSite
|
|
230
|
+
|
|
231
|
+
class AdminSite(APIAdminSite):
|
|
232
|
+
def get_authentication_classes(self):
|
|
233
|
+
from allauth.headless.contrib.rest_framework.authentication import XSessionTokenAuthentication
|
|
234
|
+
|
|
235
|
+
return [XSessionTokenAuthentication, authentication.SessionAuthentication]
|
|
236
|
+
|
|
237
|
+
site = AdminSite()
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
4. include the `django-allauth` headless urls in your `urls.py` file.
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
# urls.py
|
|
245
|
+
urlpatterns = [
|
|
246
|
+
# ...
|
|
247
|
+
path("_allauth/", include("allauth.headless.urls")),
|
|
248
|
+
]
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Now, `django-api-admin` will use the provided `authentication_classes` for authenticating users.
|
|
252
|
+
|
|
253
|
+
|
|
180
254
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
181
255
|
|
|
182
256
|
|
|
@@ -240,11 +314,8 @@ This section provides a simple example on how to use django-api-admin. If you're
|
|
|
240
314
|
- [x] Rewrite django.contrib.admin as an API
|
|
241
315
|
- [x] Add support for Bulk Actions
|
|
242
316
|
- [x] Add OpenAPI documentation
|
|
243
|
-
- [ ] Add
|
|
244
|
-
- [ ]
|
|
245
|
-
- [ ] Multi-language Support
|
|
246
|
-
- [ ] Arabic
|
|
247
|
-
- [ ] Spanish
|
|
317
|
+
- [ ] Add support for charts
|
|
318
|
+
- [ ] Add support for global full-text search
|
|
248
319
|
|
|
249
320
|
See the [open issues](https://github.com/demon-bixia/django-api-admin/issues) for a full list of proposed features (and known issues).
|
|
250
321
|
|
|
@@ -288,9 +359,9 @@ Distributed under the MIT License. See the `LICENSE` file for more information.
|
|
|
288
359
|
<!-- CONTACT -->
|
|
289
360
|
## Contact
|
|
290
361
|
|
|
291
|
-
Muhammad Salah - [@
|
|
362
|
+
Muhammad Salah - [@daemobixia](https://t.me/demonbixia) - [msbizzaccount@gmail.com](mailto:[EMAIL_ADDRESS])
|
|
292
363
|
|
|
293
|
-
Project Link: [https://github.com/demon-bixia/django-api-admin](https://github.com/
|
|
364
|
+
Project Link: [https://github.com/demon-bixia/django-api-admin](https://github.com/daemon-bixia/django-api-admin)
|
|
294
365
|
|
|
295
366
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
296
367
|
|
|
@@ -303,12 +374,8 @@ This section is dedicated to recognizing the valuable resources and contribution
|
|
|
303
374
|
|
|
304
375
|
* [Django Web Framework](https://www.djangoproject.com/)
|
|
305
376
|
* [Django Rest Framework](https://www.django-rest-framework.org/)
|
|
306
|
-
* [Simple JWT](https://github.com/jazzband/djangorestframework-simplejwt/tree/master)
|
|
307
|
-
* [Django Cors Headers](https://github.com/adamchainz/django-cors-headers)
|
|
308
377
|
* [DRF Spectacular](https://github.com/tfranzel/drf-spectacular)
|
|
309
|
-
* [Django Restful Admin](https://github.com/amirasaran/django-restful-admin)
|
|
310
378
|
* [Best README Template](https://github.com/othneildrew/Best-README-Template)
|
|
311
|
-
* [QODO AI](https://www.qodo.ai/)
|
|
312
379
|
|
|
313
380
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
314
381
|
|
|
@@ -340,4 +407,7 @@ This section is dedicated to recognizing the valuable resources and contribution
|
|
|
340
407
|
[DRF-url]: https://www.django-rest-framework.org/
|
|
341
408
|
[Django REST framework]: https://img.shields.io/badge/django--rest--framework-3.12.4-green?style=for-the-badge&labelColor=333333&logo=django&logoColor=white&color=green
|
|
342
409
|
|
|
410
|
+
[DRFSPD-url]: https://drf-spectacular.readthedocs.io/en/latest/
|
|
411
|
+
[DRF Spectacular]: https://img.shields.io/badge/drf-spectacular-orange?style=for-the-badge&labelColor=333333&logo=django&logoColor=white&color=green
|
|
412
|
+
|
|
343
413
|
[product-screenshot]: assets/images/screenshot.png
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
## Introduction
|
|
2
|
+
|
|
3
|
+
**Django API Admin** is a Django package that provides a powerful, RESTful API admin interface for your Django projects.
|
|
4
|
+
|
|
5
|
+
Key highlights include:
|
|
6
|
+
- **A Modern Rewrite:** It is a complete rewrite of the standard `django.contrib.admin` package, built on top of the **Django Rest Framework (DRF)**.
|
|
7
|
+
- **Frontend-First:** Specifically designed for developers building custom administrative front-ends using modern frameworks like **React**, **Vue**, and **Next.js**.
|
|
8
|
+
- **Full Feature Parity:** It provides a RESTful interface to all default `django.contrib.admin` features out of the box.
|
|
9
|
+
- **Extensible:** Easily customizable to add unique functionality tailored to your specific administrative needs.
|
|
10
|
+
|
|
11
|
+
## Scope
|
|
12
|
+
|
|
13
|
+
- **Core Support:** It natively supports the full suite of features found in the standard `django.contrib.admin` package.
|
|
14
|
+
- **Unopinionated Auth:** To remain flexible, it does **not** include or enforce any default authentication method.
|
|
15
|
+
- **Beyond a Mirror:** While it follows the patterns of the original admin, it is not strictly a mirror and may include enhanced features or different architectural choices that go beyond the standard Django admin.
|
|
16
|
+
|
|
17
|
+
## Authentication
|
|
18
|
+
|
|
19
|
+
Authentication is decoupled from the core package to give developers full control over their security stack.
|
|
20
|
+
|
|
21
|
+
- **Developer Responsibility:** Implementation of authentication is left entirely to the developer within their specific project.
|
|
22
|
+
- **Recommendation:** We highly recommend using [Django Allauth Headless](https://django-allauth.readthedocs.io/en/latest/headless.html) for a seamless, modern authentication experience that pairs perfectly with this package.
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Portions of this file are from Django (https://www.djangoproject.com/)
|
|
3
|
+
# Copyright (c) Django Software Foundation and individual contributors.
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
# Licensed under the BSD 3-Clause License.
|
|
6
|
+
#
|
|
7
|
+
# Additional code copyright (c) 2021 Muhammad Salah
|
|
8
|
+
# Licensed under the MIT License
|
|
9
|
+
#
|
|
10
|
+
# This file includes both Django code and your my own contributions.
|
|
11
|
+
# -----------------------------------------------------------------------------
|
|
2
12
|
|
|
13
|
+
from django_api_admin.utils.module_loading import autodiscover_modules
|
|
3
14
|
from django_api_admin.decorators import action, display, register
|
|
4
15
|
from django_api_admin.filters import (
|
|
5
16
|
AllValuesFieldListFilter,
|
|
@@ -13,8 +24,7 @@ from django_api_admin.filters import (
|
|
|
13
24
|
RelatedOnlyFieldListFilter,
|
|
14
25
|
SimpleListFilter,
|
|
15
26
|
)
|
|
16
|
-
from django_api_admin.
|
|
17
|
-
from django_api_admin.admins.model_admin import APIModelAdmin
|
|
27
|
+
from django_api_admin.admins.model_admin import APIModelAdmin, HORIZONTAL, VERTICAL
|
|
18
28
|
from django_api_admin.admins.inline_admin import StackedInlineAPI, TabularInlineAPI
|
|
19
29
|
from django_api_admin.sites import APIAdminSite, site
|
|
20
30
|
|
|
@@ -9,19 +9,15 @@ from django_api_admin.utils.get_deleted_objects import get_deleted_objects
|
|
|
9
9
|
from django_api_admin.decorators import action
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
@action(
|
|
13
|
-
permissions=['delete'],
|
|
14
|
-
description=gettext_lazy('Delete selected %(verbose_name_plural)s')
|
|
15
|
-
)
|
|
12
|
+
@action(permissions=["delete"], description=gettext_lazy("Delete selected %(verbose_name_plural)s"))
|
|
16
13
|
def delete_selected(modeladmin, request, queryset):
|
|
17
14
|
"""
|
|
18
15
|
default api_admin action deletes the selected objects
|
|
19
16
|
no confirmation page
|
|
20
17
|
"""
|
|
21
|
-
_deletable_objects, _model_count, perms_needed, _protected = get_deleted_objects(
|
|
22
|
-
queryset, request, modeladmin.admin_site)
|
|
18
|
+
_deletable_objects, _model_count, perms_needed, _protected = get_deleted_objects(queryset, request, modeladmin.admin_site)
|
|
23
19
|
|
|
24
|
-
#
|
|
20
|
+
# Check the permissions
|
|
25
21
|
if perms_needed:
|
|
26
22
|
objects_name = model_ngettext(queryset)
|
|
27
23
|
msg = _("Cannot delete %(name)s") % {"name": objects_name}
|
|
@@ -30,11 +26,9 @@ def delete_selected(modeladmin, request, queryset):
|
|
|
30
26
|
# log the deletion of all the objects inside the queryset
|
|
31
27
|
n = queryset.count()
|
|
32
28
|
if n:
|
|
33
|
-
|
|
34
|
-
modeladmin.log_deletion(request, obj, str(obj))
|
|
29
|
+
modeladmin.log_deletion(request, queryset)
|
|
35
30
|
|
|
36
|
-
#
|
|
37
|
-
|
|
38
|
-
msg = _("Successfully deleted %s %s.") % (
|
|
39
|
-
|
|
40
|
-
return Response({'detail': msg}, status=status.HTTP_200_OK)
|
|
31
|
+
# Delete the queryset
|
|
32
|
+
modeladmin.delete_queryset(request, queryset)
|
|
33
|
+
msg = _("Successfully deleted %s %s.") % (n, model_ngettext(modeladmin.opts, n))
|
|
34
|
+
return Response({"detail": msg}, status=status.HTTP_200_OK)
|