This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script language="javascript" type="text/javascript"> | |
SHARETHIS.addEntry({ | |
// defaults here | |
{block:PostTitle} title:'{PostTitle}',{/block:PostTitle} | |
{block:PostSummary} summary:'{PostSummary}',{/block:PostSummary} | |
icon:'{PortraitURL-30}', | |
url:'{Permalink}', | |
// entry type specifics here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpResponseRedirect | |
from django.conf import settings | |
from re import compile | |
EXEMPT_URLS = [compile(settings.LOGIN_URL.lstrip('/'))] | |
if hasattr(settings, 'LOGIN_EXEMPT_URLS'): | |
EXEMPT_URLS += [compile(expr) for expr in settings.LOGIN_EXEMPT_URLS] | |
class LoginRequiredMiddleware: | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# settings.py | |
LOGIN_URL = '/login/' | |
LOGIN_EXEMPT_URLS = ( | |
r'^about\.html$', | |
r'^legal/', # allow any URL under /legal/* | |
) | |
MIDDLEWARE_CLASSES = ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@login_required # This is the decorator! One line... simple. | |
def my_view(request): | |
# Do something here to turn the request into an HTML page. | |
# ... |
NewerOlder