url(r'^(?P<user_id>\d+)/$', 'auth.views.main', name='main'),I wrote a somehow custom login that works when the user inserts his credentials.
He is simply redirected to a page with url:url(r'^(?P<user_id>\d+)/$', 'auth.views.main', name='main'),Now that I try to add @login_decorators but I'm facing problems.For example, I have the view def main(request,user_id): where the redirected template after the login listens.When I add @login_required(login_url='/login/') to that main, when the user tries to login nothing happens, I remain to the login page and in the terminal I get:"GET /1000/ HTTP/1.1" 302 0"GET /login/?next=/1000/ HTTP/1.1" 200 6201What happens?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/T4a3yrBm140J.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/oPmX_2NBchQJ.
在 2012年8月8日星期三,下午6:17,mapapage 写道:I
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/oPmX_2NBchQJ.
I wrote this custom authentication backend:
在 2012年8月9日星期四,下午2:33,mapapage 写道:
I wrote this custom authentication backend:from django.contrib.auth.models import User, check_passwordfrom auth.models import Ownersclass AuthBackend(object):def authenticate(self, username=None, password=None):try:user = Owners.objects.get(id=username)
#if user.check_password(password):if user.password == password:
return userexcept User.DoesNotExist:return Nonedef get_user(self, user_id):""" Get a User object from the user_id. """try:return User.objects.get(pk=user_id)except User.DoesNotExist:return Nonebut still the decorator doesn't work..even if a user is not logged in he can access another's page just by modifying the url(r'^(?P<user_id>\d+)/$', 'auth.views.main', name='main'),(putting his id)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/HsS1FtrjJ5IJ.
I'm working with a legacy database so I should use another model (Owners) instead of the default Django
constrib.auth.models.Userfor authentication.
My model has an id field (
id = models.DecimalField(...)) that is used for username and a field for password(password = models.CharField(...))
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/WmODCM0Zj2sJ.