@login_required() dont work

150 views
Skip to first unread message

Asinox

unread,
Jul 23, 2009, 11:27:18 AM7/23/09
to Django users
Hi guys, im trying to use the login and logout functions of Django,
but my @login_required() dont work, dont redirecto to the login form
and show the view where the user need to be logged...

VIEW
from django.shortcuts import render_to_response, get_object_or_404,
Http404
from django.contrib.auth.decorators import login_required
from diligencia.diligencias.models import UserProfile, Diligencia

@login_required()
def index(request):
entradas = Diligencia.objects.all()
return render_to_response('account/listar_deligencias.html',
{'listar': entradas})


SETTINGS
LOGIN_REDIRECT_URL = '/accounts/profile/'

LOGIN_URL = '/accounts/login/'



What's wrong?

Thanks

Jonas Obrist

unread,
Jul 23, 2009, 11:41:20 AM7/23/09
to django...@googlegroups.com
that should be

@login_required
def index(request):
...


as far as i know, pretty sure your () are the problem

Superman

unread,
Jul 28, 2009, 7:23:30 PM7/28/09
to Django users
Still doesn't work :(

I have the same problem. I use python 2.5 and my code is...

from django.contrib.auth.decorators import login_required

@login_required
def vote(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
try:
...
Reply all
Reply to author
Forward
0 new messages