django-unpoly
What it does
unpoly is a reusable app for Django implementing a Django-flavored
Unpoly v2 Server Protocol.
It provides:
-
A middleware which adds
is_unpolyunpoly_target, andunpoly_validatemethods to the request object. -
A view mixin classes support both Django Generic Views and Vanilla Views.
-
A Form mixin class for Crispy Forms.
Installation
pip install unpoly_django
Configuration
You need to add unpoly.middleware.UnpolyMiddleware to your MIDDLEWARE.
To install all the middleware, you want something like:
MIDDLEWARE = (
# ...
'unpoly.middleware.UnpolyMiddleware',
# ...
)
Settings
If using the View mixins following constants to settings.py:
MAIN_UP_TARGET = '#your_main_up_target'
MAIN_UP_FAIL_TARGET = '#your_main_upfail_target'
DEFAULT_UP_ERROR_TEMPLATE = 'your-unpoly-error-template.html'
# Default Templates for various Unpoly layers.
# Override on individual View attributes.
UNPOLY_MODAL_TEMPLATE = 'your-unpoly-modal-template.html'
UNPOLY_DRAWER_TEMPLATE = 'your-unpoly-drawer-template.html'
UNPOLY_POPUP_TEMPLATE = 'your-unpoly-popup-template.html'
UNPOLY_COVER_TEMPLATE = 'your-unpoly-cover-template.html'
# Routing URL kwarg set when an optimized response is to be sent
OPTIMIZED_SUCCESS_RESPONSE = 'optimized_success_response'
DEFAULT_ERROR_VIEW = 'appname:error_view_name'
CSRF Token
Ensure that the csrf_token meta tag is included in the head section of your templates
<meta name="csrf-token" content="{{ csrf_token }}" />
View Mixins
View mixin classes add hooks and properties for sending optimized server responses to the frontend.
Add view mixin classes to Django's Generic views, or Vanilla Views:
from django.views.generic import FormView, TemplateView
from unpoly.views import UnpolyViewMixin, UnpolyFormViewMixin, UnpolyCrispyFormViewMixin
class YourTemplateView(UnpolyViewMixin, TemplateView):
pass
class YourFormView(UnpolyViewMixin, FormView):
pass
class YourCrispyFormView(UnpolyCrispyFormViewMixin, FormView):
pass
Crispy Form Mixin
The Crispy Form mixin can be used when form mixins are used, which enables passing
up-target, up-layer, up-fail-layer and up-fail-target params from views to forms:
from django.forms import ModelForm
from unpoly.forms import UnpolyCrispyFormMixin
class UnpolyCrispyForm(UnpolyCrispyFormMixin, ModelForm):
pass
Running the tests
If you have a cloned copy, run::
python3 runtests.py
Contributing
Contributions welcome! The project lives in the Github repo at thinkwelltwd/unpoly_django repository.
Bug reports and feature requests can be filed on the repository's issue tracker.
License
Released under the MIT License. There's should be a LICENSE file in the root of the repository.
The MIT License (MIT) Copyright (c) 2021, Dave Burkholder
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Change history for unpoly_django
0.1.0 ^^^^^^
- Initial release.
Metadata
Release files for unpoly-django 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| unpoly_django-0.1.0.tar.gz | 16.0 kB | Without provenance | Details for unpoly_django-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| unpoly_django-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for unpoly_django-0.1.0-py3-none-any.whl |
Total release size: 28.2 kB
Release files / unpoly_django-0.1.0.tar.gz
| Download URL | unpoly_django-0.1.0.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd41e5f9474e70fd7b7b342955619b4a2e7c2bff2a49a6b369c83fb8cae66087
|
|
BLAKE2b-256 checksum How to use checksums |
3d85772a3a845737eda4058f0fc940d7139d85b66269f93f1d56bc34919b04f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.4
|
Release files / unpoly_django-0.1.0-py3-none-any.whl
| Download URL | unpoly_django-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11fbbbce4c39e679001c88c99b4d2e0a16472fef6d83190ac847650f59b9c9db
|
|
BLAKE2b-256 checksum How to use checksums |
0247a74f385cc89f745c8c4492e60961949a503fe1a92f6c581984b8a07e7321
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.4
|
Security for unpoly-django 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.