2đź‘Ť
The problem isn’t with authenticate()
, it seems to be with login()
which you appear to be passing a unicode
into, rather than a django.contrib.auth.models.User
object.
You should probably be getting that User object from authenticate()
user = authenticate(username=username, password=password)
...
login(request, user)
👤pycruft
0đź‘Ť
The exception value tells it: “user” is a unicode object instead of a django.contrib.auth.models.User object. Are you sure that the database is accessible? try:
python manage.py shell
>>> from django.contrib.auth.models import User
>>> u = User.objects.get(pk=1)
>>> u.last_login
This code must work correctly. If not, then there’s something wrong with your database setup. (maybe you did not do python manage.py syncdb
?)
Please post your database related parts of settings.py as well. From your current information it’s not easy to find the cause of your problem.
The full traceback is helpful as well.
👤mawimawi
- [Answered ]-Django Celery throws error after changing databases
- [Answered ]-How to add markdown editor to custom django comment?
Source:stackexchange.com