Coder Social home page Coder Social logo

django-decorator-include's Introduction

django-decorator-include

Include Django URL patterns with decorators.

Installation

Installation from Source

Unpack the archive, cd to the source directory, and run the following command:

python setup.py install

Installation with pip and git

Assuming you have pip and git installed, run the following command to install from the GitHub repository:

pip install git+git://github.com/jeffkistler/django-decorator-include.git#egg=django-decorator-include

Usage

decorator_include is intended for use in URL confs as a replacement for the django.conf.urls.defaults.include function. It works in almost the same way as include, however the first argument should be either a decorator or an iterable of decorators to apply, in reverse order, to all included views. Here is an example URL conf:

from django.conf.urls.defaults import *
from django.contrib.auth.decorators import login_required

from decorator_include import decorator_include

urlpatterns = patterns('',
    url(r'^$', 'mysite.views.index', name='index'),
    url(r'^secret/', decorator_include(login_required, 'mysite.secret.urls'),
)

django-decorator-include's People

Contributors

jeffkistler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

django-decorator-include's Issues

pip install django-decorator-include fails with version 0.2

$ virtualenv test
New python executable in test/bin/python
Installing setuptools, pip...done.

$ test/bin/pip install django-decorator-include
Downloading/unpacking django-decorator-include
  Downloading django-decorator-include-0.2.tar.gz
  Running setup.py (path:/home/jon/test/build/django-decorator-include/setup.py) egg_info for package django-decorator-include

Installing collected packages: django-decorator-include
  Running setup.py install for django-decorator-include
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/jon/test/build/django-decorator-include/setup.py", line 33, in <module>
        'Programming Language :: Python :: 3.4',
      File "/usr/lib64/python2.7/distutils/core.py", line 152, in setup
        dist.run_commands()
      File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/home/jon/test/lib/python2.7/site-packages/setuptools/command/install.py", line 59, in run
        return orig.install.run(self)
      File "/usr/lib64/python2.7/distutils/command/install.py", line 563, in run
        self.run_command('build')
      File "/usr/lib64/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/lib64/python2.7/distutils/command/build.py", line 127, in run
        self.run_command(cmd_name)
      File "/usr/lib64/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/home/jon/test/lib/python2.7/site-packages/setuptools/command/build_py.py", line 42, in run
        self.build_packages()
      File "/usr/lib64/python2.7/distutils/command/build_py.py", line 372, in build_packages
        self.build_module(module, module_file, package)
      File "/home/jon/test/lib/python2.7/site-packages/setuptools/command/build_py.py", line 60, in build_module
        outfile, copied = orig.build_py.build_module(self, module, module_file, package)
      File "/usr/lib64/python2.7/distutils/command/build_py.py", line 333, in build_module
        "'package' must be a string (dot-separated), list, or tuple")
    TypeError: 'package' must be a string (dot-separated), list, or tuple
    Complete output from command /home/jon/test/bin/python -c "import setuptools, tokenize;__file__='/home/jon/test/build/django-decorator-include/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Wb40ls-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/jon/test/include/site/python2.7:
    running install

running build

running build_py

Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "/home/jon/test/build/django-decorator-include/setup.py", line 33, in <module>

    'Programming Language :: Python :: 3.4',

  File "/usr/lib64/python2.7/distutils/core.py", line 152, in setup

    dist.run_commands()

  File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands

    self.run_command(cmd)

  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command

    cmd_obj.run()

  File "/home/jon/test/lib/python2.7/site-packages/setuptools/command/install.py", line 59, in run

    return orig.install.run(self)

  File "/usr/lib64/python2.7/distutils/command/install.py", line 563, in run

    self.run_command('build')

  File "/usr/lib64/python2.7/distutils/cmd.py", line 326, in run_command

    self.distribution.run_command(command)

  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command

    cmd_obj.run()

  File "/usr/lib64/python2.7/distutils/command/build.py", line 127, in run

    self.run_command(cmd_name)

  File "/usr/lib64/python2.7/distutils/cmd.py", line 326, in run_command

    self.distribution.run_command(command)

  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command

    cmd_obj.run()

  File "/home/jon/test/lib/python2.7/site-packages/setuptools/command/build_py.py", line 42, in run

    self.build_packages()

  File "/usr/lib64/python2.7/distutils/command/build_py.py", line 372, in build_packages

    self.build_module(module, module_file, package)

  File "/home/jon/test/lib/python2.7/site-packages/setuptools/command/build_py.py", line 60, in build_module

    outfile, copied = orig.build_py.build_module(self, module, module_file, package)

  File "/usr/lib64/python2.7/distutils/command/build_py.py", line 333, in build_module

    "'package' must be a string (dot-separated), list, or tuple")

TypeError: 'package' must be a string (dot-separated), list, or tuple

----------------------------------------
Cleaning up...
Command /home/jon/test/bin/python -c "import setuptools, tokenize;__file__='/home/jon/test/build/django-decorator-include/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Wb40ls-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/jon/test/include/site/python2.7 failed with error code 1 in /home/jon/test/build/django-decorator-include
Storing debug log for failure in /home/jon/.pip/pip.log

class-based view

Is there a way to have your django-decorator-include work, in the same way, but with class-based view ?
Thx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.