1👍
✅
You cannot do it. You should not do it even if you could do it. Let’s do the operation on “request” as much as possible on “view”. like this.
def create_view(request):
user, created = User.objects.get_or_create(id=xxx)
if created:
request.session['first_login'] = True
UPDATE
Add a solution that assumes using “social-app-django“.
① set settings.SOCIAL_AUTH_NEW_USER_REDIRECT_URL
NEW_USER_REDIRECT_URL=/new/user/view
② Update session with new user view。
def new_user_view(request):
request.session['first_login'] = True
Source:stackexchange.com