spring-like request_mapping for django.
Project description
make urlpatterns very easy to use.
Requirements
django == 2.x
Install
Install and update using pip:
pip install -U django-request-mapping
A Simple Example
from django_request_mapping import request_mapping
@request_mapping("/user")
class UserView(View):
@request_mapping("/login/", method="post")
def login(self, request, *args, **kwargs):
return HttpResponse("ok")
@request_mapping("/signup/", method="post")
def register(self, request, *args, **kwargs):
return HttpResponse("ok")
@request_mapping("/<int:user_id>/role/")
def get_role(self, request, user_id):
return HttpResponse("ok")
@request_mapping("/<int:pk/", method='delete')
def delete(self, request, pk):
User.objects.filter(pk=pk).delete()
return HttpResponse("ok")
@request_mapping("/role")
class RoleView(View):
# ...
from django_request_mapping import UrlPattern
urlpatterns = UrlPattern()
urlpatterns.register(UserView)
urlpatterns.register(RoleView)
and request urls are:
post: http://localhost:8000/user/login/
post: http://localhost:8000/user/signup/
get: http://localhost:8000/user/1/role/
delete: http://localhost:8000/user/1/
# ...
Full 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.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e86ee904a8fbec5f37cb8fb6dc02ad0fb178d823be13135934b33f4280d8e1d0 |
|
MD5 | 1c19823e3a5d7d5b185bd085315e8eec |
|
BLAKE2b-256 | cfd5f005d78786714a9a1ccdfe109d26854e4549aea7b57565392736319800f3 |
Close
Hashes for django_request_mapping-0.0.9-py3.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8332e2ebabfe0930f22b82856734ec3ace490a41f046fa408a72d9d6c57b07f0 |
|
MD5 | d228f7bd4d15e2ec488c4bfd3592c6fe |
|
BLAKE2b-256 | 64416d9a75b93104601e7cfe49c01233d9185f988336f0a0809d6d57d117f877 |
Close
Hashes for django_request_mapping-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8195eff706fcb5493e9f1627bf7f6864f4262d55993a17a525d5550561c04cc |
|
MD5 | 982be0cb1e6881277373ef2847aee960 |
|
BLAKE2b-256 | 936df51ce66a0b54f8c607a16731fc64b67a1c4cd9b7c1e8960f451bcb451f7e |