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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Close
Hashes for django-request-mapping-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 094ffb0e8d4a7a708e4c945ddb216fe245ed6711a367ea7fec1af7b4a9e7c1ef |
|
MD5 | 8366cbc8a49c4f2ea6cde069ae2c6c65 |
|
BLAKE2b-256 | 1b764c68478866d1bda08bc08852900dada7b4d9719c489fb51bd7cff733576c |
Close
Hashes for django_request_mapping-0.0.5-py3.6.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef30706d85d8850458827bb05e94b23bba70060df915a238166fd7d30814177d |
|
MD5 | 76c10e544f0013e873b2c399e52536dd |
|
BLAKE2b-256 | 4b66128146e1bb80a27e01735a4f1e2ee4b63c78eb47f80afcdb67700b7ff8a8 |
Close
Hashes for django_request_mapping-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0994cfad80c2d286c1baaf3a254df9b78e2061d748a728888c2ed258885ff399 |
|
MD5 | 8d49071eec409d9c16b106d0983f86bc |
|
BLAKE2b-256 | 23ba582558f98ab9c4cc7d0cc399e23dba99e91e20d6f09e31e68b272c9b0e89 |