make django url more comfortable.
Project description
make urlpatterns very easy to use.
Requirements
django >= 2.x
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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8b39dbc5c0062d3c36e3732149506748700165811fb1fc91fc6e2e5b22f0786 |
|
MD5 | c38a0d885910e31ae18eca836aef420e |
|
BLAKE2b-256 | b9cdd734b345d5de9a63036d255edee85237f6e63baf5760524578d1cd23ac0c |
Close
Hashes for django_request_mapping-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6295fd07bacb92fafdf2c3e88a9cb662caccbe0d54d155d59de7050791187959 |
|
MD5 | 15ad09b5f9c694d3a39a529608b12f4e |
|
BLAKE2b-256 | 30624d71b01297e04b1f1ef1887ac6df9c69f80fb5c347925fc67a395d78abc6 |