You already have the user when you save the form, so you don’t need to call authenticate
since you already provide the backend when calling login()
:
user = form.save()
login(request, user, backend='django.contrib.auth.backends.ModelBackend')
More Related Contents:
- No module named MySQLdb
- Django auto_now and auto_now_add
- DatabaseError: current transaction is aborted, commands ignored until end of transaction block?
- How do I clone a Django model instance object and save it to the database?
- Django datetime issues (default=datetime.now())
- Unicodedecodeerror with runserver
- Django What is reverse relationship?
- Running “unique” tasks with celery
- URL-parameters and logic in Django class-based views (TemplateView)
- ValueError at /image/ Tensor Tensor(“activation_5/Softmax:0”, shape=(?, 4), dtype=float32) is not an element of this graph
- Django: Display Choice Value
- Django – taking values from POST request
- Django REST: Uploading and serializing multiple images
- Django Rest Framework – Authentication credentials were not provided
- Create Django model or update if exists
- Django Admin nested inline
- Get request body as string in Django
- Overriding the save method in Django ModelForm
- Django class-based view: How do I pass additional parameters to the as_view method?
- “no such table” exception
- Accessing dictionary by key in Django template
- Case insensitive unique model fields in Django?
- Proper way to consume data from RESTFUL API in django
- What is the default order of a list returned from a Django filter call?
- how to add annotate data in django-rest-framework queryset responses?
- Django — Conditional Login Redirect
- How do I access dictionary keys that contain hyphens from within a Django template?
- CSRF validation does not work on Django using HTTPS
- How to properly use the “choices” field option in Django
- How to use custom AdminSite class?