Skip to main content

Django REST framework - redux-form connector

Project description

drfrf

CircleCI PyPI

Django REST framework - redux-form connector

Installation

$ pipenv install drfrf

Usage

Import and use one of ValidateCreateMixin or ValidateUpdateMixin:

from drfrf import ValidateCreateMixin, ValidateUpdateMixin
from rest_framework import viewsets
from rest_framework.decorators import detail_route, list_route
from shop.models import CartItem
from shop.serializers import CartItemSerializer


class CartItemViewSet(ValidateCreateMixin, ValidateUpdateMixin, viewsets.ModelViewSet):
    queryset = CartItem.objects.all()
    serializer_class = CartItemSerializer

    @list_route(methods=["post"], url_path="validate")
    def validate_list(self, request):
        return self.validate_create(request)

    @detail_route(methods=["post"], url_path="validate")
    def validate_detail(self, request, **kwargs):
        return self.validate_update(request, **kwargs)

Posting invalidate data to /items/validate would return error messages:

HTTP/1.1 400 Bad Request
Content-Length: 99
Content-Type: application/json

{
    "amount": [
        "Your current credit is 36€, please top-up your account before adding to your cart."
    ]
}

Browse the complete example here: https://github.com/Theodo-UK/drfrf/tree/master/example/backend/shop

API

ValidateCreateMixin

Exposes one method: validate_create takes Request, validates the input data against the provided serializer and returns a Response.

ValidateUpdateMixin

Exposes one method: validate_update takes Request with kwargs, validates the input data against the provided serializer and returns a Response.

Frontend integration

If you're using redux-form in your frontend, check out drfrf for the front.

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

drfrf-0.0.2.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drfrf-0.0.2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file drfrf-0.0.2.tar.gz.

File metadata

  • Download URL: drfrf-0.0.2.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for drfrf-0.0.2.tar.gz
Algorithm Hash digest
SHA256 12f301878e61a0d2d20091c1d9bf3e62bb3ed7480f9141fc8539c8160f4bdeae
MD5 d9853223488f844604353edbec404f81
BLAKE2b-256 0bf0f0178c17bfa6fa08cec23afcdb23b24638afee1477a18238a500f7058d54

See more details on using hashes here.

File details

Details for the file drfrf-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: drfrf-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for drfrf-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fc1a8499e68bf882829832c9cf4e54880e659102f084248cab1cb044badc6d59
MD5 c1d86e777bc6cfe7bb08f71767f5d3e4
BLAKE2b-256 e1d77deb0844694b2225fa91e18572012246c8f9cde715b177f3765fdf7d588c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page