jpadilla/django-rest-framework-jwt

WinError 123 after tutorial

filip1333 opened this issue · 1 comments

Hi.
I tried to make this tutorial https://github.com/davesque/django-rest-framework-simplejwt.
Environment
Python 3.7.3
Django 2.2.1
djangorestframework 3.9.4
djangorestframework-jwt 1.11.0
djangorestframework-simplejwt 4.3.0
(I only make "pip install djangorestframework_simplejwt", I don't know where jwt 1.11.0 came from, when I try uninstall this I have:

> (restTutorial) C:\restTutorial>pip uninstall jwt 
> Skipping jwt as it is not installed.

Like in this tutorial, I have:
settings.py

> REST_FRAMEWORK = {
>     'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
>     'PAGE_SIZE': 10,
>     'DEFAULT_AUTHENTICATION_CLASSES': (
>         'rest_framework_simplejwt.authentication.JWTAuthentication',
>     ),
> }

And I added to INSTALLED_APPS:

> 'simplejwt'

My restTutorial/urls.py

> from django.conf.urls import include, url
> from rest_framework.schemas import get_schema_view
> from rest_framework.documentation import include_docs_urls
> from rest_framework_simplejwt.views import (
>     TokenObtainPairView,
>     TokenRefreshView,
> )
> 
> API_TITLE = 'Pastebin API'
> API_DESCRIPTION = 'A Web API for creating and viewing highlighted code snippets.'
> schema_view = get_schema_view(title=API_TITLE)
> 
> urlpatterns = [
>     url(r'^api/token/$', TokenObtainPairView.as_view(), name='token_obtain_pair'),
>     url(r'^api/token/refresh/$', TokenRefreshView.as_view(), name='token_refresh'),
>     url(r'^', include('snippets.urls')),
>     url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
>     url(r'^schema/$', schema_view),
>     url(r'^docs/', include_docs_urls(title=API_TITLE, description=API_DESCRIPTION))
> ]

And snippets/urls.py:

from django.conf.urls import url
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from snippets import views
from rest_framework.schemas import get_schema_view
from rest_framework_simplejwt.views import (
    TokenObtainPairView,
    TokenRefreshView,
)

schema_view = get_schema_view(title='Pastebin API')

router = DefaultRouter()
router.register(r'snippets', views.SnippetViewSet)
router.register(r'users', views.UserViewSet)

urlpatterns = [
    path('schema/', schema_view),
    path('', include(router.urls)),
    url(r'^api/token/$', TokenObtainPairView.as_view(), name='token_obtain_pair'),
    url(r'^api/token/refresh/$', TokenRefreshView.as_view(), name='token_refresh')
]

I tried add

from rest_framework_simplejwt.views import (
    TokenObtainPairView,
    TokenRefreshView,
)

urlpatterns = [
    ...
    url(r'^api/token/$', TokenObtainPairView.as_view(), name='token_obtain_pair'),
    url(r'^api/token/refresh/$', TokenRefreshView.as_view(), name='token_refresh'),
    ...
]

to only one of this urls.py, but have this same error.
When I try to runserver I have this:

Screen Shot 05-30-19 at 09 59 AM
Screen Shot 05-30-19 at 09 59 AM 001

Ok, I create new project in PyCharm and copy my files to new folder and it working now.