Skip to main content

make django url more comfortable.

Project description

make urlpatterns very easy to use.

Requirements

django >= 2.x

Install

pip install django-request-mapping

QuickStart

in view.py

from django_request_mapping import request_mapping


@request_mapping(value="/user")
class UserView(View):

    @request_mapping(value="/get_info/")
    def get_user_info_by_token(self, request, *args, **kwargs):
        return HttpResponse("ok")

    @request_mapping(value="/get_list/<int:year>/")
    def some_others(self, request, year, *args, **kwargs):
        return HttpResponse("ok")

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

in urls.py

from django_request_mapping import UrlPattern
urlpatterns = UrlPattern()
urlpatterns.register(UserView)

run

python manage.py runserver

and request urls are:

get:  http://localhost:8000/user/get_info/
get: http://localhost:8000/user/get_list/1999/
post:  http://localhost:8000/user/login/

example

https://github.com/sazima/django-request-mapping/tree/master/request_mapping_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.3.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

django_request_mapping-0.0.3-py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 3

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