Posts List

Django: Custom Decorator with an Argument

Tweet Sometimes you want to be able to create a decorator for functions in Django but have the ability to pass in an argument into the decorator. I came across this when I wanted to switch from the require_login decorator to check if a user was in a certain group to see the function. So the first thing I did was create a new directory in my project root called decorators and put a blank __init__.

What Rollout will be?

Tweet I have been debating just helping with fabric or writing my own app for a week now and I just think what I need and want fabric just isn’t and too much work to get it to the way I want it to be. So here are some of the things I want Rollout to be. Be able to run in console Be able to tie the Rollout API into your own python webapp Rollout output should be multiformat (xml/json) Should be threaded Should have a run_first() and run_last() method Tie in git/svn?

Reason #2 on why Django is great

Tweet The decorators that Django has are a great time saver. There are a lot of methods in your views where you only want logged in users to see. So you can use a decorator before the function to check if they are logged in or not. from django.contrib.auth.decorators import login_required @login_required def my_view(request): .... So learn to use these time savers in your project.