Reputation: 4030
When I code from rest_framework.compat import authenticate
the pycharm remains me there is an error:
File "/Users/yindeyong/PycharmProjects/newsapi/article/serilaizes.py", line 16, in <module>
from rest_framework.compat import authenticate
ImportError: cannot import name 'authenticate'
Django 2.0.4
djangorestframework 3.9.4
Any friend know how to solve this issue?
Upvotes: 0
Views: 3181
Reputation: 558
The restframework.compat
package which you're importing from is just for backward compatibility!
Is there any reason you're importing from that??!
If you're new to Django Rest Framework
(DRF
), just remark that you're using almost latest version of rest_framework
and you're up to date, and you don't need any refrence to backward compatibility! It will help you to face more less to problems!
Anyway, authentication
package of DRF
(Django Rest Framework) is directly available from rest_framework
! You could use it simply as something like this:
from rest_framework import authentication
Upvotes: 1
Reputation: 1159
From looking at the Django rest framework guide it seems that the only authentication supported is imported through:
from rest_framework import authentication
There is no authenticate within compat.py that I could find.
Upvotes: 2