An open API service indexing awesome lists of open source software.

https://github.com/eduardoklosowski/django-urldecorator

Make Django URLs with decorator
https://github.com/eduardoklosowski/django-urldecorator

Last synced: 2 months ago
JSON representation

Make Django URLs with decorator

Awesome Lists containing this project

README

        

Django URLDecorator
===================

Make Django URLs with decorator.

Example
=======

project/urls.py
---------------

.. code:: python

...

urlpatterns = [
...
url(r'^yourapp/', include('yourapp.urls')),
...
]

yourapp/urls.py
---------------

.. code:: python

from urldecorator import URLList

urlpatterns = URLList(lazy_import='yourapp.views')

yourapp/views.py
----------------

.. code:: python

from django.http import HttpResponse
from django.views.generic import View
from .urls import urlpatterns

@urlpatterns.url(r'^$')
def index_view(request):
return HttpResponse('Index')

@urlpatterns.url(r'^cbv/$')
class ClassBasedView(View):
def get(self, request, *args, **kwargs):
return HttpResponse('Class-based View')