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 Distribution
Close
Hashes for django-request-mapping-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e3bd358e190699cd6863a126950b002e30cc8026d86f6013babb60315b34900 |
|
MD5 | 9cc866f35773a03ba73500c4e8a9bbc8 |
|
BLAKE2b-256 | 37ec0415c7df203a0fbc145fb12d1055dc58f1294785f8cfa73660797c15b240 |
Close
Hashes for django_request_mapping-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32bc49cb2c90c33d194e636c1f9d43e3f587374b5fb6bc8c87e3181e868a94e6 |
|
MD5 | 39701f7d5f8ec5b5a670795ad6af74ec |
|
BLAKE2b-256 | 07af888022aa9dfc1a1795d631b0f79498d51b88dbb35af82e05576d1b617309 |