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.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35efc9b8deb917d784d2c62d6087ab07ad722e07aa4d65c6a007af8fa29e6ab5 |
|
MD5 | 9426e17097d6bd18f4339e548b488c4d |
|
BLAKE2b-256 | c0659e0df3cbb0c9fb84e75e948be86dbba63e44b9c4560a09751a69aa09e60c |
Close
Hashes for django_request_mapping-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d38ccdbab27bb1f2735ee43500977eeab2d3d7a4806c726dc7a5e9fd627d654d |
|
MD5 | 01b99dd99c322b269d9cbbd8f44c0985 |
|
BLAKE2b-256 | 95c004fa5f128354e0d7388c6e4fe0a4eb7a26c0408bcd4465831df1e5f64406 |