https://github.com/mrthearman/drf-pipeline-views
Django REST framework views using the pipeline pattern
https://github.com/mrthearman/drf-pipeline-views
clean-architecture django django-rest-framework pipelines python testable
Last synced: about 1 year ago
JSON representation
Django REST framework views using the pipeline pattern
- Host: GitHub
- URL: https://github.com/mrthearman/drf-pipeline-views
- Owner: MrThearMan
- License: mit
- Created: 2021-09-17T20:25:13.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-04-21T19:19:52.000Z (about 1 year ago)
- Last Synced: 2025-04-21T20:33:06.633Z (about 1 year ago)
- Topics: clean-architecture, django, django-rest-framework, pipelines, python, testable
- Language: Python
- Homepage: https://pypi.org/project/drf-pipeline-views/
- Size: 3.45 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Django REST Framework Pipeline Views
[![Coverage Status][coverage-badge]][coverage]
[![Workflow Status][status-badge]][status]
[![PyPI][pypi-badge]][pypi]
[![Licence][licence-badge]][licence]
[![Last Commit][commit-badge]][repo]
[![Issues][issues-badge]][issues]
[![Downloads][downloads-badge]][pypi]
[![Python Version][version-badge]][pypi]
[![Django Version][django-badge]][pypi]
```shell
pip install drf-pipeline-views
```
---
**Documentation**: [https://mrthearman.github.io/drf-pipeline-views/](https://mrthearman.github.io/drf-pipeline-views/)
**Source Code**: [https://github.com/MrThearMan/drf-pipeline-views/](https://github.com/MrThearMan/drf-pipeline-views/)
---
Inspired by a talk on [The Clean Architecture in Python][clean] by Brandon Rhodes,
**drf-pipeline-views** aims to simplify writing testable API endpoints with
[Django REST framework][drf] using the *[Pipeline Design Pattern][pipeline]*.
The main idea behind the pipeline pattern is to process data in steps. Input from the previous step
is passed to the next, resulting in a collection of "_data-in, data-out_" -functions. These functions
can be easily unit tested, since none of the functions depend on the state of the objects in the other parts
of the pipeline. Furthermore, IO can be separated into its own step, making the other parts of the
logic simpler and faster to test by not having to mock or do any other special setup around the IO.
This also means that the IO block, or in fact any other part of the application, can be replaced as long as the
data flowing through the pipeline remains the same.
```python
from pipeline_views import BasePipelineView
from .my_serializers import InputSerializer, OutputSerializer
from .my_validators import validator
from .my_services import io_func, logging_func, integration_func
class SomeView(BasePipelineView):
pipelines = {
"GET": [
InputSerializer,
validator,
io_func,
integration_func,
logging_func,
OutputSerializer,
],
}
```
Have a look at the [quickstart][quickstart] section in the documentation on basic usage.
[clean]: https://archive.org/details/pyvideo_2840___The_Clean_Architecture_in_Python
[pipeline]: https://java-design-patterns.com/patterns/pipeline/
[quickstart]: https://mrthearman.github.io/drf-pipeline-views/quickstart
[coverage-badge]: https://coveralls.io/repos/github/MrThearMan/drf-pipeline-views/badge.svg?branch=main
[status-badge]: https://img.shields.io/github/actions/workflow/status/MrThearMan/drf-pipeline-views/test.yml?branch=main
[pypi-badge]: https://img.shields.io/pypi/v/drf-pipeline-views
[licence-badge]: https://img.shields.io/github/license/MrThearMan/drf-pipeline-views
[commit-badge]: https://img.shields.io/github/last-commit/MrThearMan/drf-pipeline-views
[issues-badge]: https://img.shields.io/github/issues-raw/MrThearMan/drf-pipeline-views
[version-badge]: https://img.shields.io/pypi/pyversions/drf-pipeline-views
[downloads-badge]: https://img.shields.io/pypi/dm/drf-pipeline-views
[django-badge]: https://img.shields.io/pypi/djversions/drf-pipeline-views
[coverage]: https://coveralls.io/github/MrThearMan/drf-pipeline-views?branch=main
[status]: https://github.com/MrThearMan/drf-pipeline-views/actions/workflows/test.yml
[pypi]: https://pypi.org/project/drf-pipeline-views
[licence]: https://github.com/MrThearMan/drf-pipeline-views/blob/main/LICENSE
[repo]: https://github.com/MrThearMan/drf-pipeline-views/commits/main
[issues]: https://github.com/MrThearMan/drf-pipeline-views/issues