django-authentication

Getting `django-registration` to send you to the page you were originally trying to visit

拜拜、爱过 提交于 2019-12-02 21:06:38
django.contrib.auth has an awesome feature: When you try to access a page that's decorated by login_required , you get redirected to the login page with a next argument, so after you login you get redirected back to the page you were originally trying to access. That's good for the user flow. But, apparently django-registration does not provide a similar feature. I expected that if you register instead of login, you would also get a next thing, and after registering-n'-activating you'll get redirected to the page you were originally trying to visit. This is not the case, you're just redirected

How to enable https in Django-auth generated pages?

北慕城南 提交于 2019-12-02 19:42:48
Using the Django-auth application (Django version 1.3), I want to have my login page go to https://mysite.com/login/ . Currently, I'm using: # urls.py from django.contrib.auth.views import login urlpatterns = patterns('', url(r'^login/$', login, name='login-view'),) # navbar.html <li id="nav-login"><a href="{% url login-view %}" ><b>Login</b></a></li> which works nicely, but goes to http://mysite.com/login/ . Is there some way to tell Django-auth what prefix (https) to use, when it reverses the view name? I've read the entire manual page, and haven't found anything that covers it. Or maybe

Django-AttributeError 'User' object has no attribute 'backend' (But…it does?)

时间秒杀一切 提交于 2019-12-02 17:51:13
In order to sign users in after registering them, I manually set the user.backend property. It normally works in my views. In this instance, I'm trying to register the user via AJAX. It is raising an AttributeError. Here is my code: def register_async(request): if request.method=='POST': userform=MyUserCreationForm(request.POST) if userform.is_valid(): #username of <30 char is required by Django User model. I'm storing username as a hash of user email user=userform.save(commit=False) user.username=hash(user.email) user.backend='django.contrib.auth.backends.ModelBackend' user.save() auth.login

I get django.db.utils.IntegrityError: UNIQUE constraint failed: auth_user.username for no apparent reason

ぐ巨炮叔叔 提交于 2019-12-02 17:11:16
问题 I have a very weird situation when I create the superuser at first I get no problem, then when I run python manage.py shell and type >>> from django.contrib.auth.models import User >>> User.objects.all() I get the following <QuerySet [<User: >]> a superuser with no username , and when I try to create a second superuser(even with a different username) because this one obviously can't be used , I get the error in the title what happened to my app ? or what was new ? .. I deleted my database

Controlling Django auth user access to specific object instances

回眸只為那壹抹淺笑 提交于 2019-12-02 07:03:28
问题 In my Django project, I have various users created by Django's built-in authentication system. Each user can create their own instances of the App model. I would like to restrict user access to objects such that users can only view the instances they have created. To do that I have created this view: @login_required def appDetail(request, app_id): try: app = App.objects.get(pk=app_id) # Testing if the currently logged in user is # the same as the user that created the 'app': if request.user

Controlling Django auth user access to specific object instances

跟風遠走 提交于 2019-12-02 06:35:11
In my Django project, I have various users created by Django's built-in authentication system. Each user can create their own instances of the App model. I would like to restrict user access to objects such that users can only view the instances they have created. To do that I have created this view: @login_required def appDetail(request, app_id): try: app = App.objects.get(pk=app_id) # Testing if the currently logged in user is # the same as the user that created the 'app': if request.user.id == app.user.user.id: if request.method == 'POST': form = AppForm(request.POST, instance=app) if form

django 'User' object has no attribute 'get' error

蓝咒 提交于 2019-12-02 02:34:55
问题 I am writing an simple django application and got stuck into this error, can some one please help me my views.py looks exactly as def custom_login(request): if request.user.is_authenticated(): return HttpResponseRedirect('dashboards') return login(request, 'login.html', authentication_form=LoginForm) def custom_logout(request): return logout(request, next_page='/') def user(request): context = {'user': user, 'groups': request.user.groups.all(), 'dashboards': Dashboard} return render_to

django 'User' object has no attribute 'get' error

此生再无相见时 提交于 2019-12-02 01:24:03
I am writing an simple django application and got stuck into this error, can some one please help me my views.py looks exactly as def custom_login(request): if request.user.is_authenticated(): return HttpResponseRedirect('dashboards') return login(request, 'login.html', authentication_form=LoginForm) def custom_logout(request): return logout(request, next_page='/') def user(request): context = {'user': user, 'groups': request.user.groups.all(), 'dashboards': Dashboard} return render_to_response('registration/dashboards.html', context, context_instance=RequestContext(request)) and my forms.py

Django authentication works on Chrome, but not on Firefox

∥☆過路亽.° 提交于 2019-12-01 12:02:44
I'm having a problem where Django's login is working okay on Chrome but not on Firefox: when trying to login to a restricted portion of the site on Firefox, it simply loops back again and again to the login page; furthermore, no error message appears on the log regarding that. Interestingly, the error doesn't happen when the server is on the local machine. Does someone have a general idea of what could be causing that strange behavior? I'm using Django 1.6 on Python 2.7 Gadget this isn't much of an answer, but a linking to other similar problems. Because I don't have rep, all I can do is leave

Django authentication works on Chrome, but not on Firefox

倖福魔咒の 提交于 2019-12-01 09:46:05
问题 I'm having a problem where Django's login is working okay on Chrome but not on Firefox: when trying to login to a restricted portion of the site on Firefox, it simply loops back again and again to the login page; furthermore, no error message appears on the log regarding that. Interestingly, the error doesn't happen when the server is on the local machine. Does someone have a general idea of what could be causing that strange behavior? I'm using Django 1.6 on Python 2.7 回答1: this isn't much