django-authentication

Django 1.8 LookupError AUTH_USER_MODEL

孤街醉人 提交于 2019-12-03 17:05:05
I'm using a custon user model as such in my app called fowl . When I run syncdb or makemigrations or migrate I get a LookupError . Please help In settings.py I have defined AUTH_USER_MODEL as 'fowl.User' fowl/models.py from django.db import models from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager from django.utils import timezone from django.core.mail import send_mail from django.utils.translation import ugettext_lazy as _ class UserManager(BaseUserManager): def create_user(self, email, password=None): """ Creates and saves a User with the given email,

How to make Django admin site accessed by non-staff user?

六月ゝ 毕业季﹏ 提交于 2019-12-03 14:37:31
问题 I would like to implement a 2nd admin site which provides a subset of feature of the primary admin site. That's possible and described in the Django docs However, I would like to limit access on the primary admin site. Some users can access the 2ndary site but not the primary site. In order to implement that feature, I would like these users no to be in the staff (is_staff=False) and rewrite the AdminSite.has_permission class SecondaryAdminSite(AdminSite): def has_permission(self, request):

Why second user login redirects me to /accounts/profile/ url?

我怕爱的太早我们不能终老 提交于 2019-12-03 14:25:44
问题 I am using Django built in view for user login: url(r'^user/login/$', 'django.contrib.auth.views.login', {'template_name': 'users/templates/login.html'}, name='user-login'), After login when I goto user/login again I can login second time. I submit the form and getting: The current URL, accounts/profile/, didn't match any of these. I haven't declare this url in urls.py . What I am doing wrong? Why framework want to redirect to this url? 回答1: django.contrib.auth.views.login redirects you to

Can I change Django's auth_user.username field to be 100 chars long without breaking anything?

杀马特。学长 韩版系。学妹 提交于 2019-12-03 13:59:12
问题 Before somebody marks this question as a duplicate of this question Can django's auth_user.username be varchar(75)? How could that be done? or other such questions on SO, please read this question. The question I linked to asks this question precisely but unfortunately the answers don't address the question that was asked. Can I change the auth_user.username field to be 100 characters long by doing the following: Run ALTER table in DB for the username field Change the max_length here:

Django AUTHENTICATION_BACKENDS import error

一个人想着一个人 提交于 2019-12-03 12:28:54
What is the proper way to import a custom backend in settings.py? I currently have the following in settings.py: AUTHENTICATION_BACKENDS = ('apps.apployment_site.auth.CustomAuth') where apployment_site is the app, auth is file name, and CustomAuth is the class name. In my view, I get: ImportError: a doesn't look like a module path after I run the following code: from django.contrib.auth import authenticate from apployment_site import * authenticate(username="username", password="password") Here's my full settings.py: """Django settings for apployment project. For more information on this file,

Auto register Django auth models using custom admin site

不羁的心 提交于 2019-12-03 11:15:28
问题 I implemented authentication management using Django auth with the default admin site but then I wanted to use my own AdminSite to rewrite some behaviors: class OptiAdmin(admin.AdminSite): site_title = "Optimizer site's admin" #...Other stuff here Then registered my own models: admin_site = OptiAdmin(name='opti_admin') admin.site.register(MyModel, MyModelAdmin) #Other stuff here But when I go to the admin site I am only able to see the models I just registered, which sounds fair to me but I

login Page by using django forms

北慕城南 提交于 2019-12-03 09:28:53
问题 I am New beginner in python and django... i want to know how can i create a login form by using django forms(forms.py) 回答1: In your urls.py file link to the built in Django login view, and pass in the path to a template you wish to use as the login page: (r'^login/$', 'django.contrib.auth.views.login', { 'template_name': 'myapp/login.html' }), And here is an example of what the template my look like (from the Django docs): {% extends "mybase.html" %} {% block content %} {% if form.errors %}

Multiple Django apps, shared authentication

為{幸葍}努か 提交于 2019-12-03 09:27:01
问题 Two answers to this question, depending on whether sharing is across different sites or different subdomains Second answer: Multiple Django apps, shared authentication A user goes to site1.com and logs in. Now, if he goes to site2.com, then he should already be logged in (authenticated) at that site. site1.com and site2.com are handled by different Django apps on the same sever. I get that the sites can share the database containing the authentication tables. What I don't get is how the

django-allauth: How to set user to active only after e-mail verification

柔情痞子 提交于 2019-12-03 08:34:08
I'm using django-allauth primarily as a way to create user accounts for the admin backend. What I would like to have happen is: 1) When a user goes through the sign up procedure, send out the verification e-mail (I have this working so far) and set the user as inactive, staff, and with the "SurveyManager" group assigned to them by defult. Currently, the user is created with active set to true, staff set to false, and no groups assigned. 2) After clicking the link in their e-mail to verify their address, I'd like the user to be set to active, so they can then log in through the admin backend.

Most optimized way to delete all sessions for a specific user in Django?

喜欢而已 提交于 2019-12-03 07:03:56
问题 I'm running Django 1.3, using Sessions Middleware and Auth Middleware: # settings.py SESSION_ENGINE = django.contrib.sessions.backends.db # Persist sessions to DB SESSION_COOKIE_AGE = 1209600 # Cookies last 2 weeks Each time a user logs in from a different location (different computer/browser), a new Session() is created and saved with a unique session_id . This can result in multiple database entries for the same user. Their login persists on that node until the cookie is deleted or session