the simplest django view decorator.
Project description
Add django_moo_url in you INSTALL_APPS.
Quick Start
step1. Add autodiscover_modles in your apps.py so that sure your views.py could conduct successfully.
from django.apps import AppConfig
from django.utils.module_loading import autodiscover_modules
class MyappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'myapp'
def ready(self) -> None:
autodiscover_modules("views.py")
step 2. use the decorator in function view.
from django.http import JsonResponse
from django_moo_url import url_pattern
@url_pattern("index/")
def index(request):
return JsonResponse({"hello":"world"})
use the decorator in class view.
from django.http import JsonResponse
from django_moo_url import url_pattern
from django.views import View
class IndexView(View):
@url_pattern("index/")
def get(request):
return JsonResponse({"hello":"world"})
OK, you learn how to use this library in your django project. now, let us learn some more challenge thing.
Other Function
Add prefix
Add next code in your settings.py like this:
DJANGO_URL = {
'myapp': "api/v1/pub"
}
so, you could visit http://localhost:8000/api/v1/pub/index to get your interface you write.
About url_pattern
It could get three arguments:
url_path: required,url path you like.is_regex:False, if it'sTrue, it will usere_pathto add router.name: likepathandre_pathargument, if you don't provide, it will use your function name.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-moo-url-1.2.2.tar.gz.
File metadata
- Download URL: django-moo-url-1.2.2.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0fd5ebfc25d13097188746b54bea954660c0f39f40daae09a5ce1136859c7f6
|
|
| MD5 |
b2508f4308140a0452c33c66e687a37d
|
|
| BLAKE2b-256 |
9d6ce1add4026938777aa22558cadbcccec927b4688f9a09938919b8f7f1bd54
|
File details
Details for the file django_moo_url-1.2.2-py3-none-any.whl.
File metadata
- Download URL: django_moo_url-1.2.2-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
002246d0792dc17daa935ebfe9b38c820961f4c6ae7fe858f192a28be5a811c5
|
|
| MD5 |
8907bf4631af12facb2ee4dd2b41f004
|
|
| BLAKE2b-256 |
128d50394f79367298b3a19dae458d6d020e532091c0cd23e18471f8d1e72c8e
|