在我的旧 MacBook 坏掉后,我正在将我一直在构建的 Django Web 应用程序转移到我的新机器(MacBook Pro M1 2021)上。我目前正在为应用程序重新安装正确的软件包和扩展。
但是,当我这样做时,我目前收到以下错误python3 manage.py runserver
:
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library
(tried "gdal", "GDAL", "gdal3.3.0", "gdal3.2.0", "gdal3.1.0",
"gdal3.0.0", "gdal2.4.0", "gdal2.3.0", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0").
Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
Run Code Online (Sandbox Code Playgroud)
我创建的数据库是通过 Postgres.app 上的服务器创建的,我相信它是与 PostGIS、GDAL 等打包在一起的。
我也跑过pip3 install GDAL
并且brew install GDAL
我尝试遵循geoDjango 文档,并在终端中添加了以下内容:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/14/bin
Run Code Online (Sandbox Code Playgroud)
当我运行时which psql
它返回:/Applications/Postgres.app/Contents/Versions/14/bin/psql
我想不通。
错误的完整回溯:
Watching for file changes with StatReloader
Exception in …
Run Code Online (Sandbox Code Playgroud) 我试图确保我正确安装了 geodjango,以便我可以按照本教程进行操作。
我使用 Brew 作为 Geodjango 先决条件的安装程序:postgresql、postgis、gdal、libgeoip。
我的 gdal 版本是最新的:3.1.2。但是,当我尝试使用ogrinfo world/data/TM_WORLD_BORDERS-0.3.shp
检查 .shp 文件时,它会在控制台中返回此错误:
Unable to open datasource '[this is the name of the file here'] with the following drivers.
然后它只列出一大堆驱动程序。
我一生都不知道该怎么做,类似问题的所有其他答案都建议升级 GDAL,但我的是最新版本......
我试图找出为什么我的异步 thunk 调用没有按预期工作。当我的网站首页加载时,我试图从数据库中提取 JSON 对象数组。现在,API 已被调用,数据已被提取,但动作创建者和切片之间出现了一些问题。我正在尝试console.log
action
,state
但也没有任何结果。
我刚刚学习,redux-toolkit
所以对此还很陌生。
这是我的切片:
import { createSlice } from '@reduxjs/toolkit'
const prizesSlice = createSlice({
name: 'prizes',
initialState: {
prizesArray: [],
},
reducers: {
getPrizes(state, action) {
console.log('hello')
state.prizes = action.payload
},
},
})
export const prizesSliceActions = prizesSlice.actions
export default prizesSlice
Run Code Online (Sandbox Code Playgroud)
这是动作创建者:
import { prizesSliceActions } from './prizes-slice'
import { createAsyncThunk } from '@reduxjs/toolkit'
import * as api from '../apiClient'
// get data
export const fetchPrizeData = createAsyncThunk(
'prizesArray/getPrizes', …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将以下数据转换为:
{
title: 'The Promise',
blurb: 'Lorem Ipsum',
cover_image: 'Lorem Ipsum',
pub_year: 2002,
genre: 'Foobar'
}
Run Code Online (Sandbox Code Playgroud)
到:
[
{
col1: 'The Promise',
col2: 'Lorem Ipsum',
col3: 'Lorem Ipsum',
col4: 2002
col5: 'Foobar'
},
]
Run Code Online (Sandbox Code Playgroud)
我已经对此困惑了很长一段时间,只能让它看起来像这样,这只是单独的对象,而不是作为对象数组一部分的单个对象(从我的数据库返回的 JSON 中还有其他书籍对象)该函数需要进行迭代)
{col1: 1} //this is an id
{col2: 'The Promise'}
{col3: 'Lorem ipsum'}
{col4: Lorem Ipsum}
{col5: '2002'}
{col6: Foobar}
Run Code Online (Sandbox Code Playgroud)
这是我一直在研究的代码:
const data = React.useMemo(
() =>
props.tableData.map((object, i) => {
Object.values(object).map((value, i) => {
let col = `col${i + 1}`
const obj = …
Run Code Online (Sandbox Code Playgroud) django ×2
gdal ×2
geodjango ×2
console ×1
javascript ×1
postgis ×1
react-redux ×1
reactjs ×1
redux ×1
redux-thunk ×1
shapefile ×1