djangorestframework-simplejwt not working - django-rest-framework

I'm following a Udemy Course with user administration and I need to install this
pip install djangorestframework-simplejwt
After its installed, I need to add this to settings.py
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
)
}
But its gives me this error
ImportError: Could not import 'rest_framework_simplejwt.authentication.JWTAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ModuleNotFoundError: No module named 'pkg_resources'.
So far I haven't been been able to find anything on google

INSTALLED_APPS = [
...
'rest_framework_simplejwt',
...
]
It should be added in INSTALLED_APPS
Source: https://django-rest-framework-simplejwt.readthedocs.io/en/latest/getting_started.html

Related

AttributeError: module 'telegram.ext.filters' has no attribute 'text'

states={
MOB_NO: [MessageHandler(filters.text, reply_to)],
},
AttributeError: module 'telegram.ext.filters' has no attribute 'text'
I install pip install python-telegram-bot.
And here we import module.
from telegram.ext import (Updater, CommandHandler, MessageHandler, filters,
ConversationHandler)
When we handle messages it says.
AttributeError: module 'telegram.ext.filters' has no attribute 'text
Most probably you are using the latest version package. Downgrade the python-telegram-bot version to 13.7.
pip install python-telegram-bot==13.7 --force-reinstall
And use "Filters" with capital F
try using this one
from telegram.ext import filters
start_handler = ConversationHandler(
entry_points=[CommandHandler("start", start)],
states= {
"ONE": [MessageHandler(filters.TEXT, one)],
"TWO": [MessageHandler(filters.TEXT, two)],
},
fallbacks=[CommandHandler("cancel", start)]
)

Issue in django.core.exceptions.ImproperlyConfigured

I added social_django.middleware.SocialAuthExceptionMiddleware
MIDDLEWARE = [
'social_django.middleware.SocialAuthExceptionMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
Error:
django.core.exceptions.ImproperlyConfigured: WSGI application
'Project2.wsgi.application' could not be loaded; Error importing
module.
You defined somewhere in your settings file the following line:
WSGI_APPLICATION = 'Project2.wsgi.application'
That means you must have under your Project2 directory a wsgi.py file that declare the wsgi application. It should look like this:
import os
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
More details in the official doc here.

Adonis WebSockets Client - How to remove log statements in Nuxt.js

Adonis js v4
I saw here that I should defining NODE_ENV via Webpack DefinePlugin or rollup-plugin-replace
"#adonisjs/websocket-client": "^1.0.9"
and I did that but nothing changed, when I build the nuxt project and then nuxt start
here is my nuxt.config.js
import colors from 'vuetify/es5/util/colors'
require('dotenv').config()
import webpack from 'webpack'
export default {
...
build: {
...
plugins: [
new webpack.DefinePlugin({
'NODE_ENV': 'production'
})
]
}
...
}
The fix to this is to add a /index when importing the package in a component, which is kinda weird but cant see any solution to this.
It would look like this now:
import Ws from '#adonisjs/websocket-client/index'

Django 2.0.6 manage.py getting runserver error

I'm new on python and also try to learn a Django version 2.0.6 , so when i try to write the code with the documentation of Django here:
If faced a problem, specifically when I want to run the code, could help me to solve that issue please.
1- code (urls.py)folder polls:
from django.urls import path
from . import views
urlpatterns = [
path('',views.index, name= 'index'),
]
2- code (urls.py) folder mysite:
from django.contrib import admin
from django.urls import include,path
urlpatterns = [
path('admin/', admin.site.urls),
path('polls/',include('polls.Urls'))
]
3- code (views.py) folder mysite:
from django.http import HttpResponse
def index(request):
return HttpResponse("Hi world, you are walcome")

Visual Studio builds module but Webpack fails with "Module not found"

I'm importing a custom module like this in a .tsx file:
import { LinkContainer } from './typings/LinkContainer';
Visual Studio builds without a problem but when I try to run webpack I get the following error:
ERROR in ./Features/Menu/Menu.tsx
Module not found: Error: Can't resolve './typings/LinkContainer' in 'C:\Users\<user>\Documents\<solution>\<project>\Features\Menu'
# ./Features/Menu/Menu.tsx 19:22-56
# ./Features/App.tsx
# ./Features/index.tsx
# multi react-hot-loader/patch ./Features/index.tsx
File content for LinkContainer.d.ts:
import { ComponentClass } from "react";
import { NavLinkProps } from "react-router-dom";
type LinkContainer = ComponentClass<NavLinkProps>;
export const LinkContainer: LinkContainer;
The problem was that only type definitions were loaded and not the module itself. Solved with import { LinkContainer } from 'react-router-bootstrap';. You can read my answer here about custom types which was the reason for creating a custom type in the first place: https://stackoverflow.com/a/44046969/3850405

Resources