小编Fre*_*eon的帖子

Django TypeError:“PosixPath”类型的参数不可迭代

我正在使用最新版本的 django django 2.2.12

我尝试在使用命令迁移之前检查错误

python3 manage.py check

但随后它会引发以下错误

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python3/dist-packages/django/core/management/base.py", line 336, in run_from_argv
    connections.close_all()
  File "/usr/lib/python3/dist-packages/django/db/utils.py", line 224, in close_all
    connection.close()
  File "/usr/lib/python3/dist-packages/django/db/backends/sqlite3/base.py", line 248, in close
    if not self.is_in_memory_db():
  File "/usr/lib/python3/dist-packages/django/db/backends/sqlite3/base.py", line 367, in is_in_memory_db
    return self.creation.is_in_memory_db(self.settings_dict['NAME'])
  File "/usr/lib/python3/dist-packages/django/db/backends/sqlite3/creation.py", line 12, in is_in_memory_db
    return …
Run Code Online (Sandbox Code Playgroud)

python django python-3.x

19
推荐指数
3
解决办法
1万
查看次数

npm 错误!http://registry.npmjs.org/ansi-escapes 上的 json 响应正文无效原因:JSON 输入意外结束

我安装了 nodejs 和 npm 我尝试运行命令

npm install -g create-react-app

但它停在下面的错误处

freduah@freduah:~$ npm install -g create-react-app
npm WARN registry Unexpected warning for http://registry.npmjs.org/: Miscellaneous Warning EAI_AGAIN: request to http://registry.npmjs.org/create-react-app failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org
npm WARN registry Using stale data from http://registry.npmjs.org/ due to a request error during revalidation.
npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at http://registry.npmjs.org/ansi-escapes reason: Unexpected end of JSON input

npm ERR! A complete log of this run can be …
Run Code Online (Sandbox Code Playgroud)

node.js npm

11
推荐指数
4
解决办法
1万
查看次数

useEffect 中的 setTimeout 函数输出缓存的状态值

这很简单。我正在使用 Redux 来管理我的状态

setTimeout我在函数中有一个函数useEffect

setTimeout超时值为50000ms。

我想要 SetTimeout 处理程序做什么

50000mssetTimeout函数检查是否已收到 api 调用响应后。

如果尚未收到响应,setTimeout函数应重新启动 api 调用,因为调用将被视为超时。

回调处理程序正在做什么

之后50000ms,即使已收到响应,setTimeout 处理程序仍会重新启动 api 调用。

我尝试记录状态的输出,然后它返回缓存的状态,即使状态已传递到函数的依赖项数组useEffect并且应该已更新

进行 api 调用后,testDetails.isUpdatingTestDetails状态设置为false

我尝试了几种逻辑,但没有一个有效

逻辑1

 useEffect(() => {
         //Notice how i check if the testDetails is being updated before initiating the setTimeout callback
        if (testDetails.isUpdatingTestDetails === true) {
         
            setTimeout(() => {
// Inside the settimeout function the same check is also …
Run Code Online (Sandbox Code Playgroud)

settimeout reactjs redux react-redux

10
推荐指数
1
解决办法
1万
查看次数

箭头函数在三元运算符中不起作用

我的箭头函数在三元运算符内不起作用,并且在控制台中也没有给出错误

下面是我的代码

Holders 数组中的对象是 Html 元素

const Holders =
    [
        {
            name: accountHolder,
            target: accountHelper
        },
        {
            name: helpHolder,
            target: helpContainer
        }
    ]
const holderbg = 'rgba(128,128,128,.1)'
document.querySelector('html').onclick = (event) => {
    Holders.map(holder => {
        holder.name.getAttribute('role') == event.target.getAttribute('role') ?
            // The Arrow Function Does Not Work But The Code Runs When It is not in the function
            // replacing ()=>{} with just holder.name.style.backgroundColor = holderbg works 
            () => {
                holder.name.style.backgroundColor = holderbg
                holder.target.classList.remove('hide')
            }

            :
            // The Arrow Function Does …
Run Code Online (Sandbox Code Playgroud)

html javascript

3
推荐指数
1
解决办法
535
查看次数

无法使用 npm 安装 @material-ui/core

我尝试安装 @material-ui/core libbrary 但 npm 抛出以下错误

我用的是

npm install @material-ui

命令

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: school-demo@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from @material-ui/core@4.11.0
npm ERR! node_modules/@material-ui/core
npm ERR!   @material-ui/core@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm …
Run Code Online (Sandbox Code Playgroud)

npm material-ui

3
推荐指数
2
解决办法
2万
查看次数