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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0256287a6cd4a3e4109738bc7e622a485c215d80fbcd4920192861f42cc64cb3 |
|
MD5 | 39c7a0029b3aa9f876832c1352b806f9 |
|
BLAKE2b-256 | 935be903814f22976091a02552164d4fdc1a5128e1e1ffb3e401d67d1799ac54 |
Close
Hashes for django_request_mapping-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f07ef4380ed63186022758bad228343661e891e270550ba6a41f5b44400719b |
|
MD5 | 7dcbf97e69c010c7cfbd7f5e32406de7 |
|
BLAKE2b-256 | 888218c0d3e500aa405fc4071e334d4e9c05da4b68e18e65d1a99e8f66f8b5f6 |