from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView - authentication

modules present in requirements.txt
asgiref==3.5.2
backports.zoneinfo==0.2.1
Django==4.0.5
djangorestframework==3.13.1
djangorestframework-simplejwt==5.2.0
PyJWT==2.5.0
pytz==2022.2.1
sqlparse==0.4.2
configuration in setting.py
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASS':
['rest_framework_simplejwt.authentication.JWTAuthentication',],
}
After having all proper configuration when i try to import the simplejwt views it is not resolved.
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView

Try to mark the Project Directory as source root directory and in pycharm or ide ignore the unresolved error. It will run

Related

How to import json file in current vue default setup?

There is this answer but it is wrong as it references tsconfig.json which is non-existant in vue projects now.
How do you import a JSON file with VueJS / Typescript?
I suspect the configuration option
{
"compilerOptions": {
"resolveJsonModule": true
}
}
should go somewhere. Where?
tsconfig.json is used when you use TypeScript.
If you used the Vue CLI to build your program, it should come with Webpack.
With webpack => 2.0.0, json-loader comes by default, so you can load .json files directly with
import jsonObject from '/path/to/file.json';

es6 export default was not found but works from inside node_modules

There's the library I load with npm: #ckeditor/ckeditor5-build-classic. It works. I can use by
import ClassicEditor from '#ckeditor/ckeditor5-build-classic'
After that I pull the target file (it's specified in package.json as ./build/ckeditor.js) and put it outside of node_modules to the project's root.
I try to use it by
import ClassicEditor from './ckeditor'
But it does not work. The error is
"export 'default' (imported as 'ClassicEditor') was not found in 'ckeditor'
Why so? There's no export default construction indeed, but it works somehow from node_modules. How to make it work outside of node_modules?
To make CKEditor work in the <script type="module"> element, type:
import {} from './ckeditor.js'
or, simply:
import './ckeditor.js'

Getting org.junit.runner.RunWith is not an annotation type with Cucumber

I'm trying to set-up a Selenium + Cucumber project in Java (I'm a beginner with Java) in Intellij. This is my class that uses the Cucumber JUnit runner:
package runtest;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
#RunWith(Cucumber.class)
#CucumberOptions (
features = "C:\\Users\\my-feature.feature",
)
public class RunTest {
}
I'm getting these errors:
Error:(8, 1) java: annotation #org.junit.runner.RunWith is missing default values for elements annotationType,<init>
Error:(8, 2) java: org.junit.runner.RunWith is not an annotation type
I don't know how to resolve this or what is happening. Please help.
I had multiple RunWith classes in my project path. After pruning the project tree, it works as expected.
You don't have to provide the absolute path of the feature file if you opt to place it within your project space. The name of the feature file folder would be enough.
As an example, if you are having the following structure:
Package: Q43966680
Class: Runner
Feature File Folder: q43966680
Snapshot:
As per your usecase within #CucumberOptions you just need to mention:
#RunWith(Cucumber.class)
#Cucumber.Options (features="q43966680")
public class RunTest {
}

Module not found: Error: Can't resolve 'react-native/Libraries/Image/resolveAssetSource'

I'm adding an audio module in my current react-native project. I have tried installing several modules (react-native-sound, react-native-track-player). Getting in both modules the same Error output, which is always pointing in the 'react-native/Libraries/Image/resolveAssetsource' as module not found.
ERROR in ./node_modules/react-native-track-player/lib/index.js
Module not found: Error: Can't resolve 'react-native/Libraries/Image/resolveAssetsource' in 'D:\workspaces\web\react\blink\node_modules\react-native-track-player\lib'
# ./node_modules/react-native-track-player/lib/index.js 1:401-459
# ./node_modules/react-native-track-player/index.js
# ./components/ui/BlinkAudio/BlinkAudio.web.js
# ./components/ui/BlinkAudio/index.web.js
# ./components/dialogs/ResourceDetails/ResourceDetails.js
# ./components/dialogs/ResourceDetails/index.js
# ./components/panels/catalog/CatalogPanel.js
# ./components/parts/Main/Main.js
# ./components/parts/Main/index.js
# ./index.web.js
This is the current imports in the index file of the audio module react-native-track-player:
import { Platform, AppRegistry, DeviceEventEmitter, NativeEventEmitter, NativeModules } from 'react-native';
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetsource';
I have tried to fix this including 'resolveAssetsource' from the imports of 'react-native' as below:
import {
Platform,
AppRegistry,
DeviceEventEmitter,
NativeEventEmitter,
NativeModules,
resolveAssetsource
} from 'react-native';
But I am not pretty sure if it would be the best way and normally I don't like to touch package node-modules directly.
I also tried to exclude the audio module from webpack loaders with no result.
module: {
loaders: [
{
test: /\.js?$/,
exclude: function (modulePath) {
return (
/node_modules/.test(modulePath) &&
!/node_modules(\\|\/)react-native-track-player/.test(modulePath)
);
},
I wonder if someone could help me to find an answer and if is possible to deal with this react-native issue, as I'm thinking that these audio modules are calling wrongly the resolveAssetsource, or in the other hand, react-native doesn't provide this specific Library for third parties, I don't know.
This seems to be a syntax error issue. There is no file nor module named resolveAssetsource, the module and filename is resolveAssetSource with a capital S.
Try to remove react-native-track-player with yarn remove react-native-track-player and install it again (or delete the entire node_modules directory and run yarn install again) as the source code under react-native-track-player/lib/index.js has it properly without any errors:
import { Platform, AppRegistry, DeviceEventEmitter, NativeEventEmitter, NativeModules } from 'react-native';
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
If you use it elsewhere, you'll have to import it like this:
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
But that is not the prefered way to do it, as this method is a member of the RN Image class/component Image.resolveAssetSource(source), so, it's better to just import the Image component and use it like this:
import {
Platform,
AppRegistry,
DeviceEventEmitter,
NativeEventEmitter,
NativeModules,
Image // Add Image import
} from 'react-native';
// and use the function as of Image method
let audioAssetSource = Image.resolveAssetSource(audioSource);
Either way, you'll have the method working and resolve the asset source information.

Vue-FontAwesome: How to import all Free and Pro Icons? Duplicate declaration error

I own a FontAwesome Pro License and I use the Vue-FontAwesome Component.
When I try to import all icons from both the free and Pro repo I get an "Duplicate declaration error ..." and if I change the declaration name it can't be found anymore.
import { library } from '#fortawesome/fontawesome-svg-core'
import { fab } from '#fortawesome/free-brands-svg-icons'
import { fas } from '#fortawesome/pro-solid-svg-icons'
import { far } from '#fortawesome/pro-regular-svg-icons'
import { fal } from '#fortawesome/pro-light-svg-icons'
import { fas } from '#fortawesome/free-solid-svg-icons'
import { far } from '#fortawesome/free-regular-svg-icons'
library.add(fab)
library.add(fas)
library.add(far)
library.add(fal)
How do I import all icons from Free and Pro?
I tried to add Fontawesome pro icons to Vuetify(1.5.x). I found a solition. I share this solution with you.
First of all, in your project directory, create a file called .npmrc and add this to it:
#fortawesome:registry=https://npm.fontawesome.com/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX,
install fontawesome-pro package with npm or yarn
npm install --save-dev #fortawesome/fontawesome-pro
or
yarn add --dev #fortawesome/fontawesome-pro
Add this line in app.js or main.js
import '#fortawesome/fontawesome-pro/css/all.css'
Install pro icon packages
npm i --save #fortawesome/pro-solid-svg-icons
npm i --save #fortawesome/pro-regular-svg-icons
npm i --save #fortawesome/pro-light-svg-icons
You can use with pro icons with prefix (fas solid, far regular fal light. That's all you can use pro icons. I hope work with your project. Good Luck.
You're in effect importing multiple icon packs into to the same var for both far and fas, hence the error "Duplicate declaration".
As stated in comments, if you have FontAwesome Pro, that includes everything in FontAwesome Free. Import the pro-packages you need, and forget about the free edition.
That being said, importing the entire thing isn't ideal. If you're using a bundle manager with tree shaking (i.e webpack), it will save your application's weight impact tenfold. You rarely need all of the 5k icons.
Continuing down that road, that is; not importing the entire package: You can import different icon versions by importing and casting them. Like so:
import { library } from '#fortawesome/fontawesome-svg-core'
import { faCoffee as fasCoffee } from '#fortawesome/pro-solid-svg-icons'
import { faCoffee as farCoffee } from '#fortawesome/pro-regular-svg-icons'
import { faCoffee as falCoffee } from '#fortawesome/pro-light-svg-icons'
library.add(fasCoffee, farCoffee, falCoffee)
More on all of this in the official docs for FA-Pro.