Skip to main content

the simplest django view decorator.

Project description

Add django_simple_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.0.1.tar.gz (3.5 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.0.1-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

Details for the file django-moo-url-1.0.1.tar.gz.

File metadata

  • Download URL: django-moo-url-1.0.1.tar.gz
  • Upload date:
  • Size: 3.5 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.0.1.tar.gz
Algorithm Hash digest
SHA256 e567b07b6f2d473ef536637237f73f2a2cfc9b24731df070a47445f3b361495b
MD5 81216133072228b0af78dcc911f365a0
BLAKE2b-256 e47491ffc0673bc6e270c5ad1ca64a61f0dd87fdad53f58af2621a582069ca08

See more details on using hashes here.

File details

Details for the file django_moo_url-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_moo_url-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.2 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.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fa19b61e275e5dcc90abd1170b0c1a12792d19d3cc42c88510a4fe828a70cf6d
MD5 4f7f81c43673c49b2385cb48545d672e
BLAKE2b-256 dcdf3b20662e4ee8a915de2c70ee0e91022a08b0dbb50a676974eb20a3c7d6b4

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