django-authentication

Login to webpage from script using Requests and Django

女生的网名这么多〃 提交于 2019-12-05 21:12:12
问题 I have written a web application in Django. I need to post some data to a form from a python script. The post (r2) works correctly when login is disabled. I have the request working correctly for the login (r1), but it gives me a 404 error now for the form post (r2). The login doesn't appear to be carried over to the second request. The csrftoken and sessionid are hardcoded for testing because it wasn't recognizing them. Relevant code (url base removed): url_login='../pecasRunLog/accounts

Django : Syncdb incorrectly warns that many-to-many field is stale

ⅰ亾dé卋堺 提交于 2019-12-05 17:22:43
问题 I have a django application where one application has many-to-many relationship with a UserProfile. But whenever I do a syncdb, it warns me that app_users is stale field The following content types are stale and need to be deleted: Apps | app_users #settings.py AUTH_PROFILE_MODULE = 'kprofile.UserProfile' #Apps/models.py class app(models.Model): .... users = models.ManyToManyField(UserProfile) Now I don't use UserProfile inside view except for some authentication purposes inside rules. And a

Prevent social account creation in allauth

痞子三分冷 提交于 2019-12-05 13:26:36
Is it possible to prevent account creation under certain circumstances in allauth, preferably using the pre_social_login signal? With the current development branch you can easily do this. In your settings: SOCIALACCOUNT_ADAPTER = 'my.adapter.MySocialAccountAdapter' Then use this adapter.py: from django.http import HttpResponse from allauth.socialaccount.adapter import DefaultSocialAccountAdapter from allauth.exceptions import ImmediateHttpResponse class MySocialAccountAdapter(DefaultSocialAccountAdapter): def pre_social_login(self, request, sociallogin): raise ImmediateHttpResponse

Can I have two django projects sharing the same authentication model?

天大地大妈咪最大 提交于 2019-12-05 11:47:16
I have two very related sites, would like users using each to only to have to login once. Either two apps under one django project serving different domains? Is this possible? or is there some way to share the authentication between two separate django projects? Cheers Asim There are lots of ways you can solve this problem. Here are some things to look into. I'm ordering based on my preference, if you've got some questions, or more specificity to your question, it could change. Use the same database. Make one site an OpenID provider for the other Use Django's MultiDB functionality (NOTE! You

Show message after password change?

我怕爱的太早我们不能终老 提交于 2019-12-05 10:20:48
I'm using the default change password mechanism provided by django. I'm using post_change_redirect to have the submitted form go straight back to my settings page, however I'd like to show a message to reassure the user that the operation has been successful. How can I detect whether I'm arriving in my settings view as the result of a successful password change, and add a message to that effect? I wouldn't recommend checking in the settings view whether a user has arrived via a password change. I think that ideally, all of the logic for password changes is contained in the same place. This

Custom Authentication for non-user connection with Django Rest Framework

◇◆丶佛笑我妖孽 提交于 2019-12-05 10:07:28
I have enabled user authentication with DRF using TokenAuthentication REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', 'rest_framework.authentication.SessionAuthentication' ), 'DEFAULT_MODEL_SERIALIZER_CLASS': 'rest_framework.serializers.ModelSerializer', 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.AllowAny', ), #'EXCEPTION_HANDLER': 'apps.core.exceptions.custom_exception_handler' } I have the following model: class Device(CreationModificationMixin): """ Contains devices (WW controllers). A device may be associated with

django: failing tests from django.contrib.auth

大憨熊 提交于 2019-12-05 08:32:36
When I run my django test I get following errors, that are outside of my test suite: ====================================================================== ERROR: test_known_user (django.contrib.auth.tests.remote_user.RemoteUserCustomTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 160, in test_known_user super(RemoteUserCustomTest, self).test_known_user() File "/usr/lib/pymodules/python2.6/django/contrib/auth/tests/remote_user.py", line 67, in test

Django 1.7 multisite User model

戏子无情 提交于 2019-12-05 05:02:45
I want to serve a Django application that serves multiple web sites by single database but different user sets. Think like a blog application, it will be used by several domains with different themes, but use same database by adding a site field to models. I use Django's SitesFramework for that job. But the problem is, I couldn't separate user models for different sites. I want to use same user model with a site field and email field that unique per site. I tried to extend AbstractUser model like that: from django.contrib.auth.models import AbstractUser from django.contrib.sites.models import

Removing sessions from Redis (Django)

白昼怎懂夜的黑 提交于 2019-12-05 03:26:02
问题 I'm using Django and Redis as session engine (also Celery, but that is something else). It works perfectly and I can see an improvement in speed. SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' I have a script that runs every minute to check the active users through some methods and if the user hasn't been active in the latest minute, then the session gets removed. This is done for customer's tracking needs. This script was working perfectly until I switched to Redis as a

How to make Django REST JWT Authentication scale with mulitple webservers?

删除回忆录丶 提交于 2019-12-05 02:14:31
问题 I currently have a Django app that is simply a bunch of REST APIs (backed by a database of course). I am managing my authentications with Django REST framework JWT. It's working fine. Whenever a user logs in, one of my API returns a token that the consuming application stores for later usage. So far so good. However, in the future, this solution will need to scale. And instead of having a single server running the Django app, I can forsee a situation when I will need multiple Webservers. Of