django-authentication

Implementing Ajax requests / response with django-allauth

末鹿安然 提交于 2019-12-17 18:25:06
问题 I am using django-allauth for one of my project. I would like to implement login/signup process via ajax. I would like to have customized signup form. I was going through their signupmixin and signup form. Sounds like I can write custom views for each action and map it to the url config. I am not sure what is the best way to do this. Thank you so much for any help or advice on this. 回答1: It depends a bit on what you mean by ajax. If you just want to have a popup-style login/signup box on

Django's admin does not login after custom authentication

感情迁移 提交于 2019-12-14 03:34:11
问题 The custom authentication I wrote follows the instructions from the docs. I am able to register, login, and logout the user, no problem there. Then, when I create a superuser python manage.py createsuperuser , it creates a user in the database, but it does not let me login when I go to the admin page and try to login saying Please enter the correct email address and password for a staff account. Note that both fields may be case-sensitive. Here is my code: models.py: from __future__ import

How to change root URL configuration in order to use a namespace for the user URLs

跟風遠走 提交于 2019-12-14 03:08:18
问题 Site-Wide URL: from user import urls as user_urls app_name='user' urlpatterns = [ re_path(r'^user/',include(user_urls)), ] Since the admin app, also defines URL patterns named login and logout in django/contrib/admin/sites.py . I need Django pointing to user app. It's still pointing towards registration/login.html (i.e admin app). I tried namespacing but its been removed in Django 2.0. user/urls.py : urlpatterns = [ path(r'',RedirectView.as_view()), re_path( r'^login/$',auth_views.LoginView

What is the 'right' way to extend the username field length in Django 1.5+?

一笑奈何 提交于 2019-12-14 02:52:05
问题 Usernames in Django are limited to max_length=30 , and since Django 1.5+ they can also be set by using USERNAME_FIELD . However, it isn't clear how the existing username field can be kept intact (with all the functionality it has) while only changing max_length . I assume some sort of monkey patching is required, but it isn't immediate what the right way to do so is. This question is not a duplicate of existing questions that refer to versions prior to 1.5, rather it asks about a very

Persist Django user in session

谁都会走 提交于 2019-12-14 02:38:36
问题 I am using RemoteUserMiddleware to authenticate with VAS. Right now I set it up so the REMOTE_USER variable gets set only for my SSO login URL ( /accounts/login/sso/ ), because I must allow my users to login via forms (for users not present in our SSO system). According to my debugging, the user gets authenticated correctly in VasMiddleware (which extends RemoteUserMiddleware to pre-process REMOTE_USER ), but after the user gets redirected to the home page ( / ), authentication is lost. How

form_valid method in django-extra-views. In reality form(s)_valid

独自空忆成欢 提交于 2019-12-13 20:28:23
问题 I am trying to use Django Extra Views pack to create new entry based on model + inline formset + extra information from the USER model. I know how to do it via function based views but now trying to decrease amount of the code: I have 2 models + user model: Model1: # primary model author = models.ForeignKey("ExtraUser", ) +some fileds Model2 # secondary model photo = models.ForeignKey("Model1", ) + some fields # user model Model ExtraUser(AbstractBaseUser) + some fileds I use following VIEW

NoReverseMatch at /user/password_reset/ Reverse for 'password_reset_done' not found

浪尽此生 提交于 2019-12-13 17:59:41
问题 I'm trying to use the Django authentication system, but I'm getting the error: enter image description here 'user' is an app name. Project's urls.py: from django.conf.urls import url, include from django.contrib import admin from django.conf import settings from django.conf.urls.static import static urlpatterns = [ url(r'^admin/', admin.site.urls), ... url(r'^user/', include('user.urls', namespace='user')), ... ] user/urls.py: from django.conf.urls import url, include from . import views

Extending the Django 1.11 User Model

久未见 提交于 2019-12-13 15:23:38
问题 I am attempting to work out how to extend the Django user model to add information to a user. I can't seem to get it to work. What am I doing wrong? Is it okay to have foreignkeys within the same model I am extending in to? How do you create a superuser, or do you have to do it manually through the python manage.py shell ? Here's my code so far: class PersonModel(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) firstName = models.CharField(max_length=50) lastName =

update user and user profile on same form

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 05:17:23
问题 i created userProfile for some additional user information. here my model: class UserProfile(models.Model): user = models.OneToOneField(User) picture = models.ImageField(upload_to=get_upload_path, blank=True) def __unicode__(self): return self.user.username def create_user_profile(sender, **kwargs): u = kwargs["instance"] if not UserProfile.objects.filter(user=u): UserProfile(user=u).save() post_save.connect(create_user_profile, sender=User) I need settings page and in this page i will update

request.user.is_authenticated always returns false

跟風遠走 提交于 2019-12-13 02:27:52
问题 after logging in the user and checking whether request.user isauthenticated in other activity in android. the value is always false. the following code is used for login a user from rest_framework.response import Response from rest_framework import status from rest_framework.decorators import api_view from django.contrib.auth.models import User from django.contrib.auth import authenticate,logout,login @api_view(['POST']) def userRegister(request): user=User.objects.create_user(username