Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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.

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

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page