Skip to main content

spring-like request_mapping for django.

Project description

Make urlpatterns more human-readable.


django == 2.x

notice: I haven't tested it in version 3.x, so I don't know if it is supported, if there is any result, you can tell me


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):
        data = request.POST
        return HttpResponse("ok")

    @request_mapping("/signup/", method="post")
    def signup(self, request):
        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.

Files for django-request-mapping, version 0.0.12
Filename, size File type Python version Upload date Hashes
Filename, size django_request_mapping-0.0.12-py3-none-any.whl (17.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-request-mapping-0.0.12.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page