Skip to main content

spring-like request_mapping for django.

Project description

make urlpatterns very easy to use.


django == 2.x


Install and update using pip:

pip install -U  django-request-mapping

A Simple Example

from django_request_mapping import request_mapping

class UserView(View):

    @request_mapping("/login/", method="post")
    def login(self, request, *args, **kwargs):
        return HttpResponse("ok")

    @request_mapping("/signup/", method="post")
    def register(self, request, *args, **kwargs):
        return HttpResponse("ok")

    def get_role(self, request, user_id):
       return HttpResponse("ok") 

    @request_mapping("/<int:pk/", method='delete')
    def delete(self, request, pk):
        return HttpResponse("ok")

class RoleView(View):
    # ...

from django_request_mapping import UrlPattern
urlpatterns = UrlPattern()

and request urls are:

post:  http://localhost:8000/user/login/
post:  http://localhost:8000/user/signup/
get:  http://localhost:8000/user/1/role/
delete: http://localhost:8000/user/1/
# ...

Full Example

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

django-request-mapping-0.0.9.tar.gz (4.1 kB view hashes)

Uploaded source

Built Distributions

django_request_mapping-0.0.9-py3.7.egg (9.3 kB view hashes)

Uploaded 3 7

Supported by

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