django-login

How to use a signup form outside of the /accounts/ url pattern with Django-AllAuth?

醉酒当歌 提交于 2019-12-11 03:19:43
问题 I'm currently using django-allauth to manage my registrations and logins. Until now, all of my logins and signups have worked by having the django-allauth pages at the /accounts/ prefix for url patterns, so to register a new account you would navigate to /accounts/signup/ . I want to keep this functionality, but also want to introduce a signup form onto my landing page (at my base url), and I want to have a quick login form in my top banner from anywhere in my website (not /accounts/ ). My

Django - Error Message in Custom Auth Backend

杀马特。学长 韩版系。学妹 提交于 2019-12-10 18:13:35
问题 I have written a custom auth backend by extending the defalut ModelBackend. Is it possible to send a custom error message to login screen? As of now it is displaying the default message. 回答1: The error messages are coming as ValidationError exceptions raised by django.contrib.auth.forms.AuthenticationForm . You would need to extend the Authentication Form or implement your own authentication form to change it's error messages. 回答2: You can raise a django ValidationError from django.core

Django login with django-axes

我的未来我决定 提交于 2019-12-01 04:14:00
I created a site with django. Users should be able to login. The login-view looks like this: from django.contrib.auth import authenticate, login from django.contrib.auth.models import User .... if request.method == 'POST': username = request.POST['username']#get username password = request.POST['txtPwd']# and password user = authenticate(username=username, password=password) #checking username and pwd if user is not None: if user.is_active: login(request, user) But with this "solution" i can't handle an brute force attack. So I looked around and found this: Throttling brute force login attacks

Set all pages to require login, globally?

▼魔方 西西 提交于 2019-11-30 04:15:07
I want to redirect access of unauthenticated users to the login page, after which the logged-in user should be redirected to the originally requested page. According to documentation, this is easily achieved using the @user_passes_test decorator. But it seems I'd have to decorate every view, which is crazy, there are too many and it's error-prone. What is a good way to turn on this functionality globally (except for a small fixed set of views, such as login )? That is, default everything to logged-in-only + handle anonymous viewing explicitly, where needed. have a look at middleware . these

NoReverseMatch while rendering: Reverse for ''django.contrib.auth.views.login''

天大地大妈咪最大 提交于 2019-11-30 01:35:16
I'm using Django's authentication, and in the login.html template, the following statement is generating an error: {% url 'django.contrib.auth.views.login' %} TemplateSyntaxError at /login Caught NoReverseMatch while rendering: Reverse for ''django.contrib.auth.views.login'' with arguments '()' and keyword arguments '{}' not found. This url is defined in my urls.py: (r'^login$', 'django.contrib.auth.views.login') I have installed the auth system: INSTALLED_APPS = ( 'django.contrib.auth', ... ) Any ideas? Dominic Rodger As of Django 1.10: As of Django 1.10, it is no longer possible to use the

NoReverseMatch while rendering: Reverse for ''django.contrib.auth.views.login''

佐手、 提交于 2019-11-28 22:23:27
问题 I'm using Django's authentication, and in the login.html template, the following statement is generating an error: {% url 'django.contrib.auth.views.login' %} TemplateSyntaxError at /login Caught NoReverseMatch while rendering: Reverse for ''django.contrib.auth.views.login'' with arguments '()' and keyword arguments '{}' not found. This url is defined in my urls.py: (r'^login$', 'django.contrib.auth.views.login') I have installed the auth system: INSTALLED_APPS = ( 'django.contrib.auth', ...

Log in user using either email address or username in Django

余生长醉 提交于 2019-11-28 16:43:59
I am trying to create an auth backend to allow my users to log in using either their email address or their username in Django 1.6 with a custom user model. The backend works when I log in with a user name but for some reason does not with an email. Is there something I am forgetting to do? from django.conf import settings from django.contrib.auth.models import User class EmailOrUsernameModelBackend(object): """ This is a ModelBacked that allows authentication with either a username or an email address. """ def authenticate(self, username=None, password=None): if '@' in username: kwargs = {

Django - user permissions to certain views?

倾然丶 夕夏残阳落幕 提交于 2019-11-27 13:38:38
问题 From the admin I see that you can allocate permissions to a user or a user group to :allow add, change or delete data from a model. That is great, but I also need to allow a user or a user group to access or not a group of views. I have certain type of services on my web site so I want to allow some users to access a certain services (pages/views) but not others. So how can I allow certain users/user groups access to certain views? Thank you! 回答1: Users that cannot add or change etc. a

Log in user using either email address or username in Django

五迷三道 提交于 2019-11-27 09:46:49
问题 I am trying to create an auth backend to allow my users to log in using either their email address or their username in Django 1.6 with a custom user model. The backend works when I log in with a user name but for some reason does not with an email. Is there something I am forgetting to do? from django.conf import settings from django.contrib.auth.models import User class EmailOrUsernameModelBackend(object): """ This is a ModelBacked that allows authentication with either a username or an