Skip to main content

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's True, it will use re_path to add router.
  • name: like path and re_path argument, if you don't provide, it will use your function name.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-moo-url-1.2.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_moo_url-1.2.2-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

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

Hashes for django-moo-url-1.2.2.tar.gz
Algorithm Hash digest
SHA256 b0fd5ebfc25d13097188746b54bea954660c0f39f40daae09a5ce1136859c7f6
MD5 b2508f4308140a0452c33c66e687a37d
BLAKE2b-256 9d6ce1add4026938777aa22558cadbcccec927b4688f9a09938919b8f7f1bd54

See more details on using hashes here.

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

Hashes for django_moo_url-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 002246d0792dc17daa935ebfe9b38c820961f4c6ae7fe858f192a28be5a811c5
MD5 8907bf4631af12facb2ee4dd2b41f004
BLAKE2b-256 128d50394f79367298b3a19dae458d6d020e532091c0cd23e18471f8d1e72c8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page