drf-commons 1.0.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.
- drf_commons-1.0.0/.flake8 +22 -0
- drf_commons-1.0.0/LICENSE +21 -0
- drf_commons-1.0.0/MANIFEST.in +27 -0
- drf_commons-1.0.0/PKG-INFO +323 -0
- drf_commons-1.0.0/README.md +252 -0
- drf_commons-1.0.0/drf_commons/__init__.py +7 -0
- drf_commons-1.0.0/drf_commons/common_conf/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/common_conf/django_settings.py +131 -0
- drf_commons-1.0.0/drf_commons/common_conf/settings.py +211 -0
- drf_commons-1.0.0/drf_commons/common_conf/test_urls.py +13 -0
- drf_commons-1.0.0/drf_commons/common_tests/__init__.py +7 -0
- drf_commons-1.0.0/drf_commons/common_tests/base_cases.py +110 -0
- drf_commons-1.0.0/drf_commons/common_tests/conftest.py +56 -0
- drf_commons-1.0.0/drf_commons/common_tests/factories.py +81 -0
- drf_commons-1.0.0/drf_commons/common_tests/serializers/__init__.py +21 -0
- drf_commons-1.0.0/drf_commons/common_tests/serializers/base.py +16 -0
- drf_commons-1.0.0/drf_commons/common_tests/serializers/fields.py +47 -0
- drf_commons-1.0.0/drf_commons/common_tests/utils.py +184 -0
- drf_commons-1.0.0/drf_commons/current_user/__init__.py +11 -0
- drf_commons-1.0.0/drf_commons/current_user/apps.py +8 -0
- drf_commons-1.0.0/drf_commons/current_user/tests/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/current_user/tests/test_utils.py +96 -0
- drf_commons-1.0.0/drf_commons/current_user/utils.py +43 -0
- drf_commons-1.0.0/drf_commons/debug/__init__.py +33 -0
- drf_commons-1.0.0/drf_commons/debug/apps.py +8 -0
- drf_commons-1.0.0/drf_commons/debug/core/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/debug/core/categories.py +114 -0
- drf_commons-1.0.0/drf_commons/debug/logger.py +67 -0
- drf_commons-1.0.0/drf_commons/debug/logging/__init__.py +19 -0
- drf_commons-1.0.0/drf_commons/debug/logging/config.py +47 -0
- drf_commons-1.0.0/drf_commons/debug/logging/directories.py +15 -0
- drf_commons-1.0.0/drf_commons/debug/logging/formatters.py +17 -0
- drf_commons-1.0.0/drf_commons/debug/logging/handlers/__init__.py +87 -0
- drf_commons-1.0.0/drf_commons/debug/logging/handlers/specs.py +75 -0
- drf_commons-1.0.0/drf_commons/debug/logging/loggers/__init__.py +71 -0
- drf_commons-1.0.0/drf_commons/debug/logging/loggers/specs.py +103 -0
- drf_commons-1.0.0/drf_commons/debug/tests/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/debug/tests/test_categories.py +151 -0
- drf_commons-1.0.0/drf_commons/debug/tests/test_logger.py +170 -0
- drf_commons-1.0.0/drf_commons/debug/tests/test_utils.py +368 -0
- drf_commons-1.0.0/drf_commons/debug/utils.py +271 -0
- drf_commons-1.0.0/drf_commons/decorators/__init__.py +24 -0
- drf_commons-1.0.0/drf_commons/decorators/cache.py +49 -0
- drf_commons-1.0.0/drf_commons/decorators/database.py +58 -0
- drf_commons-1.0.0/drf_commons/decorators/logging.py +158 -0
- drf_commons-1.0.0/drf_commons/decorators/performance.py +58 -0
- drf_commons-1.0.0/drf_commons/decorators/tests/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/decorators/tests/test_cache.py +224 -0
- drf_commons-1.0.0/drf_commons/decorators/tests/test_database.py +239 -0
- drf_commons-1.0.0/drf_commons/decorators/tests/test_logging.py +274 -0
- drf_commons-1.0.0/drf_commons/decorators/tests/test_performance.py +185 -0
- drf_commons-1.0.0/drf_commons/filters/__init__.py +12 -0
- drf_commons-1.0.0/drf_commons/filters/apps.py +8 -0
- drf_commons-1.0.0/drf_commons/filters/ordering/__init__.py +19 -0
- drf_commons-1.0.0/drf_commons/filters/ordering/computed.py +53 -0
- drf_commons-1.0.0/drf_commons/filters/ordering/processors.py +76 -0
- drf_commons-1.0.0/drf_commons/filters/ordering/tests/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/filters/ordering/tests/test_computed.py +218 -0
- drf_commons-1.0.0/drf_commons/filters/ordering/tests/test_processors.py +178 -0
- drf_commons-1.0.0/drf_commons/filters/tests/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/middlewares/__init__.py +20 -0
- drf_commons-1.0.0/drf_commons/middlewares/current_user.py +31 -0
- drf_commons-1.0.0/drf_commons/middlewares/debug.py +187 -0
- drf_commons-1.0.0/drf_commons/middlewares/tests/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/middlewares/tests/test_current_user.py +198 -0
- drf_commons-1.0.0/drf_commons/middlewares/tests/test_debug.py +500 -0
- drf_commons-1.0.0/drf_commons/models/__init__.py +62 -0
- drf_commons-1.0.0/drf_commons/models/base.py +91 -0
- drf_commons-1.0.0/drf_commons/models/content.py +213 -0
- drf_commons-1.0.0/drf_commons/models/fields.py +85 -0
- drf_commons-1.0.0/drf_commons/models/mixins.py +128 -0
- drf_commons-1.0.0/drf_commons/models/person.py +311 -0
- drf_commons-1.0.0/drf_commons/models/tests/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/models/tests/test_base.py +142 -0
- drf_commons-1.0.0/drf_commons/models/tests/test_content.py +487 -0
- drf_commons-1.0.0/drf_commons/models/tests/test_fields.py +188 -0
- drf_commons-1.0.0/drf_commons/models/tests/test_mixins.py +294 -0
- drf_commons-1.0.0/drf_commons/models/tests/test_person.py +257 -0
- drf_commons-1.0.0/drf_commons/pagination/__init__.py +13 -0
- drf_commons-1.0.0/drf_commons/pagination/apps.py +8 -0
- drf_commons-1.0.0/drf_commons/pagination/base.py +26 -0
- drf_commons-1.0.0/drf_commons/pagination/tests/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/pagination/tests/test_base.py +45 -0
- drf_commons-1.0.0/drf_commons/response/__init__.py +19 -0
- drf_commons-1.0.0/drf_commons/response/apps.py +8 -0
- drf_commons-1.0.0/drf_commons/response/tests/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/response/tests/test_utils.py +146 -0
- drf_commons-1.0.0/drf_commons/response/utils.py +110 -0
- drf_commons-1.0.0/drf_commons/serializers/__init__.py +94 -0
- drf_commons-1.0.0/drf_commons/serializers/apps.py +8 -0
- drf_commons-1.0.0/drf_commons/serializers/base.py +56 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/__init__.py +86 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/base.py +146 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/custom.py +52 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/many.py +122 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/mixins.py +185 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/readonly.py +65 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/single.py +161 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/tests/__init__.py +10 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/tests/test_base.py +119 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/tests/test_custom.py +91 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/tests/test_many.py +141 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/tests/test_mixins.py +216 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/tests/test_readonly.py +108 -0
- drf_commons-1.0.0/drf_commons/serializers/fields/tests/test_single.py +145 -0
- drf_commons-1.0.0/drf_commons/services/__init__.py +16 -0
- drf_commons-1.0.0/drf_commons/services/export_file/__init__.py +10 -0
- drf_commons-1.0.0/drf_commons/services/export_file/data_processor.py +169 -0
- drf_commons-1.0.0/drf_commons/services/export_file/exporters/__init__.py +8 -0
- drf_commons-1.0.0/drf_commons/services/export_file/exporters/csv_exporter.py +69 -0
- drf_commons-1.0.0/drf_commons/services/export_file/exporters/pdf_exporter.py +142 -0
- drf_commons-1.0.0/drf_commons/services/export_file/exporters/tests/__init__.py +8 -0
- drf_commons-1.0.0/drf_commons/services/export_file/exporters/tests/test_csv_exporter.py +90 -0
- drf_commons-1.0.0/drf_commons/services/export_file/exporters/tests/test_pdf_exporter.py +90 -0
- drf_commons-1.0.0/drf_commons/services/export_file/exporters/tests/test_xlsx_exporter.py +99 -0
- drf_commons-1.0.0/drf_commons/services/export_file/exporters/xlsx_exporter.py +139 -0
- drf_commons-1.0.0/drf_commons/services/export_file/service.py +132 -0
- drf_commons-1.0.0/drf_commons/services/export_file/tests/__init__.py +8 -0
- drf_commons-1.0.0/drf_commons/services/export_file/tests/test_data_processor.py +77 -0
- drf_commons-1.0.0/drf_commons/services/export_file/tests/test_service.py +81 -0
- drf_commons-1.0.0/drf_commons/services/export_file/tests/test_utils.py +24 -0
- drf_commons-1.0.0/drf_commons/services/export_file/utils.py +108 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/__init__.py +15 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/config/__init__.py +9 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/config/config_helpers.py +73 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/config/config_validator.py +293 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/config/enums.py +13 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/config/tests/__init__.py +8 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/config/tests/test_config_helpers.py +78 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/config/tests/test_config_validator.py +102 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/config/tests/test_enums.py +37 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/core/__init__.py +9 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/core/bulk_operations.py +168 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/core/exceptions.py +25 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/core/file_reader.py +76 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/core/tests/__init__.py +8 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/core/tests/test_bulk_operations.py +78 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/core/tests/test_exceptions.py +74 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/core/tests/test_file_reader.py +116 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/data_processor/__init__.py +7 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/data_processor/data_processor.py +106 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/data_processor/field_processor.py +267 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/data_processor/lookup_manager.py +105 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/data_processor/object_manager.py +180 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/data_processor/tests/__init__.py +9 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/data_processor/tests/test_data_processor.py +81 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/data_processor/tests/test_field_processor.py +36 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/data_processor/tests/test_lookup_manager.py +58 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/data_processor/tests/test_object_manager.py +36 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/service.py +274 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/tests/__init__.py +6 -0
- drf_commons-1.0.0/drf_commons/services/import_from_file/tests/test_service.py +85 -0
- drf_commons-1.0.0/drf_commons/services/management/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/services/management/commands/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/services/management/commands/generate_import_template.py +470 -0
- drf_commons-1.0.0/drf_commons/services/management/tests/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/services/tests/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/templates/exports/pdf_template.html +198 -0
- drf_commons-1.0.0/drf_commons/templates/exports/tests/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/templatetags/__init__.py +1 -0
- drf_commons-1.0.0/drf_commons/templatetags/dict_extras.py +11 -0
- drf_commons-1.0.0/drf_commons/templatetags/tests/__init__.py +0 -0
- drf_commons-1.0.0/drf_commons/tests/__init__.py +5 -0
- drf_commons-1.0.0/drf_commons/tests/test_e2e.py +418 -0
- drf_commons-1.0.0/drf_commons/tests/test_installation.py +269 -0
- drf_commons-1.0.0/drf_commons/tests/test_middleware_integration.py +251 -0
- drf_commons-1.0.0/drf_commons/tests/test_service_integration.py +362 -0
- drf_commons-1.0.0/drf_commons/tests/test_viewset_integration.py +483 -0
- drf_commons-1.0.0/drf_commons/urls/__init__.py +3 -0
- drf_commons-1.0.0/drf_commons/utils/__init__.py +3 -0
- drf_commons-1.0.0/drf_commons/utils/middleware_checker.py +70 -0
- drf_commons-1.0.0/drf_commons/utils/tests/__init__.py +3 -0
- drf_commons-1.0.0/drf_commons/utils/tests/test_middleware_checker.py +81 -0
- drf_commons-1.0.0/drf_commons/views/__init__.py +55 -0
- drf_commons-1.0.0/drf_commons/views/apps.py +8 -0
- drf_commons-1.0.0/drf_commons/views/base.py +165 -0
- drf_commons-1.0.0/drf_commons/views/mixins/__init__.py +51 -0
- drf_commons-1.0.0/drf_commons/views/mixins/bulk.py +227 -0
- drf_commons-1.0.0/drf_commons/views/mixins/crud.py +203 -0
- drf_commons-1.0.0/drf_commons/views/mixins/import_export.py +396 -0
- drf_commons-1.0.0/drf_commons/views/mixins/tests/__init__.py +9 -0
- drf_commons-1.0.0/drf_commons/views/mixins/tests/test_bulk.py +92 -0
- drf_commons-1.0.0/drf_commons/views/mixins/tests/test_crud.py +140 -0
- drf_commons-1.0.0/drf_commons/views/mixins/tests/test_import_export.py +64 -0
- drf_commons-1.0.0/drf_commons/views/mixins/tests/test_utils.py +60 -0
- drf_commons-1.0.0/drf_commons/views/mixins/utils.py +49 -0
- drf_commons-1.0.0/drf_commons/views/tests/__init__.py +6 -0
- drf_commons-1.0.0/drf_commons/views/tests/test_base.py +202 -0
- drf_commons-1.0.0/drf_commons.egg-info/PKG-INFO +323 -0
- drf_commons-1.0.0/drf_commons.egg-info/SOURCES.txt +196 -0
- drf_commons-1.0.0/drf_commons.egg-info/dependency_links.txt +1 -0
- drf_commons-1.0.0/drf_commons.egg-info/not-zip-safe +1 -0
- drf_commons-1.0.0/drf_commons.egg-info/requires.txt +49 -0
- drf_commons-1.0.0/drf_commons.egg-info/top_level.txt +1 -0
- drf_commons-1.0.0/pyproject.toml +130 -0
- drf_commons-1.0.0/requirements.txt +15 -0
- drf_commons-1.0.0/setup.cfg +4 -0
- drf_commons-1.0.0/setup.py +64 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[flake8]
|
|
2
|
+
max-line-length = 88
|
|
3
|
+
extend-ignore =
|
|
4
|
+
# E203: whitespace before ':'
|
|
5
|
+
E203,
|
|
6
|
+
# W503: line break before binary operator
|
|
7
|
+
W503,
|
|
8
|
+
# E501: line too long (let black handle this)
|
|
9
|
+
E501
|
|
10
|
+
exclude =
|
|
11
|
+
.git,
|
|
12
|
+
__pycache__,
|
|
13
|
+
.venv,
|
|
14
|
+
venv,
|
|
15
|
+
env,
|
|
16
|
+
migrations,
|
|
17
|
+
build,
|
|
18
|
+
dist,
|
|
19
|
+
*.egg-info
|
|
20
|
+
per-file-ignores =
|
|
21
|
+
# F401: imported but unused
|
|
22
|
+
__init__.py:F401
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Victoire HABAMUNGU
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Include documentation
|
|
2
|
+
include README.md
|
|
3
|
+
include LICENSE
|
|
4
|
+
include requirements.txt
|
|
5
|
+
|
|
6
|
+
# Include configuration files
|
|
7
|
+
include pyproject.toml
|
|
8
|
+
include setup.py
|
|
9
|
+
include .flake8
|
|
10
|
+
|
|
11
|
+
# Include all package data
|
|
12
|
+
recursive-include drf_commons *.py
|
|
13
|
+
recursive-include drf_commons/templates *
|
|
14
|
+
recursive-include drf_commons/static *
|
|
15
|
+
|
|
16
|
+
# Exclude unnecessary files
|
|
17
|
+
recursive-exclude * __pycache__
|
|
18
|
+
recursive-exclude * *.py[co]
|
|
19
|
+
recursive-exclude * .DS_Store
|
|
20
|
+
recursive-exclude * *.so
|
|
21
|
+
recursive-exclude * *.dylib
|
|
22
|
+
exclude .coverage
|
|
23
|
+
exclude htmlcov
|
|
24
|
+
exclude .gitignore
|
|
25
|
+
recursive-exclude tests *
|
|
26
|
+
recursive-exclude htmlcov *
|
|
27
|
+
recursive-exclude .pytest_cache *
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: drf-commons
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Django REST Framework Common Utilities - Modular apps for enhanced DRF functionality
|
|
5
|
+
Author: Victoire HABAMUNGU
|
|
6
|
+
Author-email: Victoire HABAMUNGU <contact@htvictoire.me>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/htvictoire/drf-common
|
|
9
|
+
Project-URL: Repository, https://github.com/htvictoire/drf-common
|
|
10
|
+
Project-URL: Issues, https://github.com/htvictoire/drf-common/issues
|
|
11
|
+
Keywords: django,rest-framework,drf,utilities,api
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Framework :: Django
|
|
24
|
+
Classifier: Framework :: Django :: 3.2
|
|
25
|
+
Classifier: Framework :: Django :: 4.0
|
|
26
|
+
Classifier: Framework :: Django :: 4.1
|
|
27
|
+
Classifier: Framework :: Django :: 4.2
|
|
28
|
+
Classifier: Framework :: Django :: 5.0
|
|
29
|
+
Classifier: Framework :: Django :: 5.1
|
|
30
|
+
Requires-Python: >=3.8
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Requires-Dist: Django>=3.2
|
|
34
|
+
Requires-Dist: djangorestframework>=3.12
|
|
35
|
+
Provides-Extra: current-user
|
|
36
|
+
Provides-Extra: debug
|
|
37
|
+
Provides-Extra: filters
|
|
38
|
+
Provides-Extra: pagination
|
|
39
|
+
Provides-Extra: response
|
|
40
|
+
Provides-Extra: serializers
|
|
41
|
+
Provides-Extra: views
|
|
42
|
+
Provides-Extra: export
|
|
43
|
+
Requires-Dist: openpyxl>=3.0; extra == "export"
|
|
44
|
+
Requires-Dist: weasyprint>=60.0; extra == "export"
|
|
45
|
+
Provides-Extra: import
|
|
46
|
+
Requires-Dist: openpyxl>=3.0; extra == "import"
|
|
47
|
+
Requires-Dist: pandas>=1.3; extra == "import"
|
|
48
|
+
Provides-Extra: config
|
|
49
|
+
Requires-Dist: django-constance>=2.9; extra == "config"
|
|
50
|
+
Provides-Extra: all
|
|
51
|
+
Requires-Dist: openpyxl>=3.0; extra == "all"
|
|
52
|
+
Requires-Dist: weasyprint>=60.0; extra == "all"
|
|
53
|
+
Requires-Dist: pandas>=1.3; extra == "all"
|
|
54
|
+
Requires-Dist: django-constance>=2.9; extra == "all"
|
|
55
|
+
Provides-Extra: dev
|
|
56
|
+
Requires-Dist: black==25.1.0; extra == "dev"
|
|
57
|
+
Requires-Dist: flake8==7.3.0; extra == "dev"
|
|
58
|
+
Requires-Dist: isort==6.0.1; extra == "dev"
|
|
59
|
+
Requires-Dist: mypy==1.18.1; extra == "dev"
|
|
60
|
+
Provides-Extra: test
|
|
61
|
+
Requires-Dist: pytest==8.4.2; extra == "test"
|
|
62
|
+
Requires-Dist: pytest-cov==7.0.0; extra == "test"
|
|
63
|
+
Requires-Dist: pytest-django==4.11.1; extra == "test"
|
|
64
|
+
Requires-Dist: factory-boy>=3.3; extra == "test"
|
|
65
|
+
Provides-Extra: build
|
|
66
|
+
Requires-Dist: build>=1.0; extra == "build"
|
|
67
|
+
Requires-Dist: twine>=6.0; extra == "build"
|
|
68
|
+
Dynamic: author
|
|
69
|
+
Dynamic: license-file
|
|
70
|
+
Dynamic: requires-python
|
|
71
|
+
|
|
72
|
+
# DRF Commons
|
|
73
|
+
|
|
74
|
+
> **⚠️ UNDER DEVELOPMENT**: This library is currently under active development. APIs may change, and some features may not be fully stable yet.
|
|
75
|
+
|
|
76
|
+
A comprehensive collection of reusable Django REST Framework utilities and components designed to accelerate API development.
|
|
77
|
+
|
|
78
|
+
## Features
|
|
79
|
+
|
|
80
|
+
### Core Modules
|
|
81
|
+
|
|
82
|
+
- **Current User**: Middleware and utilities for accessing the current user context
|
|
83
|
+
- **Debug**: Advanced logging and debugging tools with categorized loggers
|
|
84
|
+
- **Decorators**: Performance monitoring, caching, database optimization, and logging decorators
|
|
85
|
+
- **Filters**: Enhanced filtering and ordering capabilities including computed fields
|
|
86
|
+
- **Middlewares**: Current user tracking and debug middleware
|
|
87
|
+
- **Models**: Base models, mixins, and custom fields for common patterns
|
|
88
|
+
- **Pagination**: Flexible pagination classes
|
|
89
|
+
- **Response**: Standardized API response utilities
|
|
90
|
+
- **Serializers**: Enhanced serializers with custom fields and mixins
|
|
91
|
+
- **Views**: ViewSet mixins for CRUD, bulk operations, and import/export
|
|
92
|
+
|
|
93
|
+
### Services
|
|
94
|
+
|
|
95
|
+
- **Export File**: Export data to CSV, XLSX, and PDF formats
|
|
96
|
+
- **Import from File**: Robust file import with validation and bulk operations
|
|
97
|
+
|
|
98
|
+
## Installation
|
|
99
|
+
|
|
100
|
+
Install the base package:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pip install drf-commons
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Install with specific features:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# For export functionality (XLSX and PDF)
|
|
110
|
+
pip install drf-commons[export]
|
|
111
|
+
|
|
112
|
+
# For import functionality
|
|
113
|
+
pip install drf-commons[import]
|
|
114
|
+
|
|
115
|
+
# For dynamic configuration
|
|
116
|
+
pip install drf-commons[config]
|
|
117
|
+
|
|
118
|
+
# For all features
|
|
119
|
+
pip install drf-commons[all]
|
|
120
|
+
|
|
121
|
+
# For development
|
|
122
|
+
pip install drf-commons[dev,test]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Quick Start
|
|
126
|
+
|
|
127
|
+
### 1. Add to INSTALLED_APPS
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
INSTALLED_APPS = [
|
|
131
|
+
# ... your apps
|
|
132
|
+
'drf_commons.current_user',
|
|
133
|
+
'drf_commons.debug',
|
|
134
|
+
'drf_commons.filters',
|
|
135
|
+
'drf_commons.pagination',
|
|
136
|
+
'drf_commons.response',
|
|
137
|
+
'drf_commons.serializers',
|
|
138
|
+
'drf_commons.views',
|
|
139
|
+
]
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 2. Add Middleware (Optional)
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
MIDDLEWARE = [
|
|
146
|
+
# ... other middleware
|
|
147
|
+
'drf_commons.middlewares.current_user.CurrentUserMiddleware',
|
|
148
|
+
'drf_commons.middlewares.debug.DebugMiddleware',
|
|
149
|
+
]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 3. Use in Your Code
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
from drf_commons.views.base import BaseViewSet
|
|
156
|
+
from drf_commons.serializers.base import BaseSerializer
|
|
157
|
+
from drf_commons.models.base import BaseModel
|
|
158
|
+
from drf_commons.pagination.base import CustomPageNumberPagination
|
|
159
|
+
|
|
160
|
+
class MyModel(BaseModel):
|
|
161
|
+
# Your model fields
|
|
162
|
+
pass
|
|
163
|
+
|
|
164
|
+
class MySerializer(BaseSerializer):
|
|
165
|
+
class Meta:
|
|
166
|
+
model = MyModel
|
|
167
|
+
fields = '__all__'
|
|
168
|
+
|
|
169
|
+
class MyViewSet(BaseViewSet):
|
|
170
|
+
queryset = MyModel.objects.all()
|
|
171
|
+
serializer_class = MySerializer
|
|
172
|
+
pagination_class = CustomPageNumberPagination
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Usage Examples
|
|
176
|
+
|
|
177
|
+
### Export Data
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
from drf_commons.services import ExportService
|
|
181
|
+
|
|
182
|
+
service = ExportService()
|
|
183
|
+
|
|
184
|
+
# Export to CSV (no optional dependencies required)
|
|
185
|
+
response = service.export_csv(
|
|
186
|
+
data_rows=data,
|
|
187
|
+
includes=['id', 'name', 'created_at'],
|
|
188
|
+
column_config={},
|
|
189
|
+
filename='export.csv',
|
|
190
|
+
export_headers=[],
|
|
191
|
+
document_titles=[]
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
# Export to XLSX (requires openpyxl)
|
|
195
|
+
response = service.export_xlsx(...)
|
|
196
|
+
|
|
197
|
+
# Export to PDF (requires weasyprint)
|
|
198
|
+
response = service.export_pdf(...)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Import Data
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
from drf_commons.services import FileImportService
|
|
205
|
+
|
|
206
|
+
config = {
|
|
207
|
+
'model': MyModel,
|
|
208
|
+
'fields': {
|
|
209
|
+
'name': {'required': True},
|
|
210
|
+
'email': {'required': True, 'unique': True},
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
service = FileImportService(config)
|
|
215
|
+
result = service.import_file(file_path)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Use Decorators
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
from drf_commons.decorators.performance import measure_performance
|
|
222
|
+
from drf_commons.decorators.cache import cached_method
|
|
223
|
+
|
|
224
|
+
class MyViewSet(BaseViewSet):
|
|
225
|
+
@measure_performance
|
|
226
|
+
@cached_method(timeout=300)
|
|
227
|
+
def expensive_operation(self):
|
|
228
|
+
# Your expensive operation
|
|
229
|
+
pass
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Requirements
|
|
233
|
+
|
|
234
|
+
- Python >= 3.8
|
|
235
|
+
- Django >= 3.2
|
|
236
|
+
- djangorestframework >= 3.12
|
|
237
|
+
|
|
238
|
+
## Optional Dependencies
|
|
239
|
+
|
|
240
|
+
Different features require different dependencies:
|
|
241
|
+
|
|
242
|
+
### Core Package (No optional dependencies)
|
|
243
|
+
|
|
244
|
+
The base installation includes:
|
|
245
|
+
|
|
246
|
+
- Models, Serializers, Views, Pagination, Response utilities
|
|
247
|
+
- CSV export (no additional dependencies required)
|
|
248
|
+
- Filters, Decorators, Middleware
|
|
249
|
+
|
|
250
|
+
### File Export (`[export]`)
|
|
251
|
+
|
|
252
|
+
For XLSX and PDF export functionality:
|
|
253
|
+
|
|
254
|
+
- `openpyxl >= 3.0` - Excel (XLSX) export
|
|
255
|
+
- `weasyprint >= 60.0` - PDF export
|
|
256
|
+
|
|
257
|
+
### File Import (`[import]`)
|
|
258
|
+
|
|
259
|
+
For importing data from CSV and Excel files:
|
|
260
|
+
|
|
261
|
+
- `pandas >= 1.3` - Data processing and file parsing
|
|
262
|
+
- `openpyxl >= 3.0` - Excel file reading
|
|
263
|
+
|
|
264
|
+
### Dynamic Configuration (`[config]`)
|
|
265
|
+
|
|
266
|
+
For runtime configuration management:
|
|
267
|
+
|
|
268
|
+
- `django-constance >= 2.9` - Dynamic Django settings
|
|
269
|
+
|
|
270
|
+
## Development
|
|
271
|
+
|
|
272
|
+
### Setup Development Environment
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
# Clone the repository
|
|
276
|
+
git clone https://github.com/yourusername/drf-common.git
|
|
277
|
+
cd drf-common
|
|
278
|
+
|
|
279
|
+
# Create virtual environment
|
|
280
|
+
python -m venv venv
|
|
281
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
282
|
+
|
|
283
|
+
# Install in development mode with all dependencies
|
|
284
|
+
pip install -e .[dev,test,all]
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Run Tests
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
pytest
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Code Quality
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
# Format code
|
|
297
|
+
black .
|
|
298
|
+
|
|
299
|
+
# Sort imports
|
|
300
|
+
isort .
|
|
301
|
+
|
|
302
|
+
# Lint
|
|
303
|
+
flake8
|
|
304
|
+
|
|
305
|
+
# Type checking
|
|
306
|
+
mypy drf_commons
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Contributing
|
|
310
|
+
|
|
311
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
312
|
+
|
|
313
|
+
## License
|
|
314
|
+
|
|
315
|
+
This project is licensed under the MIT License.
|
|
316
|
+
|
|
317
|
+
## Author
|
|
318
|
+
|
|
319
|
+
Victoire HABAMUNGU
|
|
320
|
+
|
|
321
|
+
## Support
|
|
322
|
+
|
|
323
|
+
For issues and questions, please use the GitHub issue tracker.
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# DRF Commons
|
|
2
|
+
|
|
3
|
+
> **⚠️ UNDER DEVELOPMENT**: This library is currently under active development. APIs may change, and some features may not be fully stable yet.
|
|
4
|
+
|
|
5
|
+
A comprehensive collection of reusable Django REST Framework utilities and components designed to accelerate API development.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
### Core Modules
|
|
10
|
+
|
|
11
|
+
- **Current User**: Middleware and utilities for accessing the current user context
|
|
12
|
+
- **Debug**: Advanced logging and debugging tools with categorized loggers
|
|
13
|
+
- **Decorators**: Performance monitoring, caching, database optimization, and logging decorators
|
|
14
|
+
- **Filters**: Enhanced filtering and ordering capabilities including computed fields
|
|
15
|
+
- **Middlewares**: Current user tracking and debug middleware
|
|
16
|
+
- **Models**: Base models, mixins, and custom fields for common patterns
|
|
17
|
+
- **Pagination**: Flexible pagination classes
|
|
18
|
+
- **Response**: Standardized API response utilities
|
|
19
|
+
- **Serializers**: Enhanced serializers with custom fields and mixins
|
|
20
|
+
- **Views**: ViewSet mixins for CRUD, bulk operations, and import/export
|
|
21
|
+
|
|
22
|
+
### Services
|
|
23
|
+
|
|
24
|
+
- **Export File**: Export data to CSV, XLSX, and PDF formats
|
|
25
|
+
- **Import from File**: Robust file import with validation and bulk operations
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
Install the base package:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install drf-commons
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Install with specific features:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# For export functionality (XLSX and PDF)
|
|
39
|
+
pip install drf-commons[export]
|
|
40
|
+
|
|
41
|
+
# For import functionality
|
|
42
|
+
pip install drf-commons[import]
|
|
43
|
+
|
|
44
|
+
# For dynamic configuration
|
|
45
|
+
pip install drf-commons[config]
|
|
46
|
+
|
|
47
|
+
# For all features
|
|
48
|
+
pip install drf-commons[all]
|
|
49
|
+
|
|
50
|
+
# For development
|
|
51
|
+
pip install drf-commons[dev,test]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
### 1. Add to INSTALLED_APPS
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
INSTALLED_APPS = [
|
|
60
|
+
# ... your apps
|
|
61
|
+
'drf_commons.current_user',
|
|
62
|
+
'drf_commons.debug',
|
|
63
|
+
'drf_commons.filters',
|
|
64
|
+
'drf_commons.pagination',
|
|
65
|
+
'drf_commons.response',
|
|
66
|
+
'drf_commons.serializers',
|
|
67
|
+
'drf_commons.views',
|
|
68
|
+
]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 2. Add Middleware (Optional)
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
MIDDLEWARE = [
|
|
75
|
+
# ... other middleware
|
|
76
|
+
'drf_commons.middlewares.current_user.CurrentUserMiddleware',
|
|
77
|
+
'drf_commons.middlewares.debug.DebugMiddleware',
|
|
78
|
+
]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 3. Use in Your Code
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from drf_commons.views.base import BaseViewSet
|
|
85
|
+
from drf_commons.serializers.base import BaseSerializer
|
|
86
|
+
from drf_commons.models.base import BaseModel
|
|
87
|
+
from drf_commons.pagination.base import CustomPageNumberPagination
|
|
88
|
+
|
|
89
|
+
class MyModel(BaseModel):
|
|
90
|
+
# Your model fields
|
|
91
|
+
pass
|
|
92
|
+
|
|
93
|
+
class MySerializer(BaseSerializer):
|
|
94
|
+
class Meta:
|
|
95
|
+
model = MyModel
|
|
96
|
+
fields = '__all__'
|
|
97
|
+
|
|
98
|
+
class MyViewSet(BaseViewSet):
|
|
99
|
+
queryset = MyModel.objects.all()
|
|
100
|
+
serializer_class = MySerializer
|
|
101
|
+
pagination_class = CustomPageNumberPagination
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Usage Examples
|
|
105
|
+
|
|
106
|
+
### Export Data
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from drf_commons.services import ExportService
|
|
110
|
+
|
|
111
|
+
service = ExportService()
|
|
112
|
+
|
|
113
|
+
# Export to CSV (no optional dependencies required)
|
|
114
|
+
response = service.export_csv(
|
|
115
|
+
data_rows=data,
|
|
116
|
+
includes=['id', 'name', 'created_at'],
|
|
117
|
+
column_config={},
|
|
118
|
+
filename='export.csv',
|
|
119
|
+
export_headers=[],
|
|
120
|
+
document_titles=[]
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
# Export to XLSX (requires openpyxl)
|
|
124
|
+
response = service.export_xlsx(...)
|
|
125
|
+
|
|
126
|
+
# Export to PDF (requires weasyprint)
|
|
127
|
+
response = service.export_pdf(...)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Import Data
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from drf_commons.services import FileImportService
|
|
134
|
+
|
|
135
|
+
config = {
|
|
136
|
+
'model': MyModel,
|
|
137
|
+
'fields': {
|
|
138
|
+
'name': {'required': True},
|
|
139
|
+
'email': {'required': True, 'unique': True},
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
service = FileImportService(config)
|
|
144
|
+
result = service.import_file(file_path)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Use Decorators
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from drf_commons.decorators.performance import measure_performance
|
|
151
|
+
from drf_commons.decorators.cache import cached_method
|
|
152
|
+
|
|
153
|
+
class MyViewSet(BaseViewSet):
|
|
154
|
+
@measure_performance
|
|
155
|
+
@cached_method(timeout=300)
|
|
156
|
+
def expensive_operation(self):
|
|
157
|
+
# Your expensive operation
|
|
158
|
+
pass
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Requirements
|
|
162
|
+
|
|
163
|
+
- Python >= 3.8
|
|
164
|
+
- Django >= 3.2
|
|
165
|
+
- djangorestframework >= 3.12
|
|
166
|
+
|
|
167
|
+
## Optional Dependencies
|
|
168
|
+
|
|
169
|
+
Different features require different dependencies:
|
|
170
|
+
|
|
171
|
+
### Core Package (No optional dependencies)
|
|
172
|
+
|
|
173
|
+
The base installation includes:
|
|
174
|
+
|
|
175
|
+
- Models, Serializers, Views, Pagination, Response utilities
|
|
176
|
+
- CSV export (no additional dependencies required)
|
|
177
|
+
- Filters, Decorators, Middleware
|
|
178
|
+
|
|
179
|
+
### File Export (`[export]`)
|
|
180
|
+
|
|
181
|
+
For XLSX and PDF export functionality:
|
|
182
|
+
|
|
183
|
+
- `openpyxl >= 3.0` - Excel (XLSX) export
|
|
184
|
+
- `weasyprint >= 60.0` - PDF export
|
|
185
|
+
|
|
186
|
+
### File Import (`[import]`)
|
|
187
|
+
|
|
188
|
+
For importing data from CSV and Excel files:
|
|
189
|
+
|
|
190
|
+
- `pandas >= 1.3` - Data processing and file parsing
|
|
191
|
+
- `openpyxl >= 3.0` - Excel file reading
|
|
192
|
+
|
|
193
|
+
### Dynamic Configuration (`[config]`)
|
|
194
|
+
|
|
195
|
+
For runtime configuration management:
|
|
196
|
+
|
|
197
|
+
- `django-constance >= 2.9` - Dynamic Django settings
|
|
198
|
+
|
|
199
|
+
## Development
|
|
200
|
+
|
|
201
|
+
### Setup Development Environment
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# Clone the repository
|
|
205
|
+
git clone https://github.com/yourusername/drf-common.git
|
|
206
|
+
cd drf-common
|
|
207
|
+
|
|
208
|
+
# Create virtual environment
|
|
209
|
+
python -m venv venv
|
|
210
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
211
|
+
|
|
212
|
+
# Install in development mode with all dependencies
|
|
213
|
+
pip install -e .[dev,test,all]
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Run Tests
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
pytest
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Code Quality
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
# Format code
|
|
226
|
+
black .
|
|
227
|
+
|
|
228
|
+
# Sort imports
|
|
229
|
+
isort .
|
|
230
|
+
|
|
231
|
+
# Lint
|
|
232
|
+
flake8
|
|
233
|
+
|
|
234
|
+
# Type checking
|
|
235
|
+
mypy drf_commons
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Contributing
|
|
239
|
+
|
|
240
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
241
|
+
|
|
242
|
+
## License
|
|
243
|
+
|
|
244
|
+
This project is licensed under the MIT License.
|
|
245
|
+
|
|
246
|
+
## Author
|
|
247
|
+
|
|
248
|
+
Victoire HABAMUNGU
|
|
249
|
+
|
|
250
|
+
## Support
|
|
251
|
+
|
|
252
|
+
For issues and questions, please use the GitHub issue tracker.
|
|
File without changes
|