I have installed djangorestframework-simplejwt package and trying to import that module in urls.py and views.py but still its not working. Please guide me to solve this issue.
pip list
Package Version
----------------------------- -------
asgiref 3.3.1
Django 3.1.4
djangorestframework 3.12.2
djangorestframework-simplejwt 4.6.0
pip 20.2.3
PyJWT 1.7.1
pytz 2020.4
setuptools 49.2.1
sqlparse 0.4.1
Settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'Django_MedicalApp',
'rest_framework',
'rest_framework_simplejwt',]
REST_FRAMEWORK = {'DEFAULT_AUTHENTICATION_CLASSES':
['rest_framework_simplejwt.authentication.JWTAuthentication',],
'DEFAULT_PERMISSION_CLASSES':
('rest_framework.permissions.AllowAny','rest_framework.permissions.IsAuthenticatedOrReadOnly',)}
urls.py
from rest_framework_simplejwt.views import TokenObtainPairView
router = routers.DefaultRouter()
router.register('Company',views.CompanyViewset,basename='Company')
urlpatterns = [
path('admin/', admin.site.urls),
path('api/',include(router.urls),
path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'))]
views.py
from rest_framework_simplejwt.authentication import JWTAuthentication
class CompanyViewset(viewsets.ViewSet):
authentication_classes = [JWTAuthentication]
Please help me to resolve this import error.
change your interpreter to something else and then choose your virtual env back again. it will work 100%. After installing the simplejwt the interpreter needs to be reset which is achieved by changing the env to something else and back to the virtual env you use normally

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With