Generic views for Model View Serializer (MVS) pattern
Project description
Django Generic Ellis Views
Django Generic Ellis Views provides generic views for Create, Retrieve, Update, and Delete operations, requiring only the definition of serializer, model, and authorization methods.
Table of Contents
- Quick Start
- Usage Example
- Features
- Contributing
- License
Quick Start
-
Add
'ellis_django_views'to yourINSTALLED_APPSinsettings.py:# django-project/settings.py INSTALLED_APPS = [ 'ellis_django_views', ]
-
Include test URLs for testing purposes in your project's
urls.py:# django-project/urls.py from django.urls import path, include from ellis_django_views.tests import urls as TestUrls from ellis_django_views.utils import url_paths as test_url_paths urlpatterns = [ path(test_url_paths.TEST, include(TestUrls)), ]
-
Run migrations:
python manage.py makemigrations python manage.py migrate
-
Run tests:
python manage.py test ellis_django_views
Usage Example
-
Import CRUD views from
'ellis_django_views.views_implementation'and your own models and serializers:# django-project/django-app/views.py from DjangoApp.models import YourModel from DjangoApp.serializers import YourSerializer from ellis_django_views.views_implementation import ( CreateViewImpl, RequestViewImpl, UpdateViewImpl, DeleteViewImpl )
-
Create an
is_authorisedfunction which retrieves'HTTP_AUTHORIZATION'from request headers:def is_authorised(self, auth_token): "Placeholder for authorization" return True
-
Create CRUD views with imported
'ellis_django_views.views_implementation'views and youris_authorisedfunction:# django-project/django-app/views.py class CreateView(CreateViewImpl): serializer_model = YourSerializer is_authorised = is_authorised class RequestView(RequestViewImpl): model = YourModel serializer_model = YourSerializer is_authorised = is_authorised class UpdateView(UpdateViewImpl): model = YourModel serializer_model = YourSerializer is_authorised = is_authorised class DeleteView(DeleteViewImpl): model = YourModel is_authorised = is_authorised
-
Add the CRUD views to your
urls.py:# django-project/django-app/urls.py from django.urls import path from DjangoApp.views import CreateView, RequestView, UpdateView, DeleteView urlpatterns = [ path('post/', CreateView.as_view(), name='create'), path('get/', RequestView.as_view(), name='get'), path('put/', UpdateView.as_view(), name='put'), path('delete/', DeleteView.as_view(), name='delete'), ]
Features
- Simplified CRUD Operations: Easily create, retrieve, update, and delete views with minimal setup.
- Authorization Support: Implement custom authorization logic.
- Serializer Integration: Define serializers for your models to handle validation and representation.
- Test URLs: Built-in support for testing your views.
Contributing
If you have any suggestions or would like to contribute, please get in contact with Carl Ellis.
License
This project is licensed under the GNU General Public License Version 3 - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ellis_django_views-0.224.tar.gz.
File metadata
- Download URL: ellis_django_views-0.224.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a8c38c541bfa09c86baea8b505fdca0bb60cbfb2abf8a8352be8e11707bd470
|
|
| MD5 |
e158b863dc1f20482f668872bc59e4e1
|
|
| BLAKE2b-256 |
ad36225f795377b54cda63555e0cb9dcb91fb350c08547d952962881fe92d908
|
File details
Details for the file ellis_django_views-0.224-py3-none-any.whl.
File metadata
- Download URL: ellis_django_views-0.224-py3-none-any.whl
- Upload date:
- Size: 23.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
539252efdb1ae777bceab2bbe585d154b5bd33c6c3213f3720197ed693133431
|
|
| MD5 |
360d10f7a24f1b1868b74f00a0616405
|
|
| BLAKE2b-256 |
d3ef82a5912ab85d512438fa9b14d00e8e2e3493099b0f384e6c883a1790e828
|