为什么我在尝试使用 postgis 时出现此错误

问题描述 投票:0回答:1

当我进行迁移时,出现此错误。

(project) PS D:\University\FYP\final_project\land_management_system> python manage.py makemigrations
Traceback (most recent call last):
  File "D:\University\FYP\final_project\land_management_system\manage.py", line 22, in <module>
    main()
  File "D:\University\FYP\final_project\land_management_system\manage.py", line 18, in main    
    execute_from_command_line(sys.argv)
  File "D:\University\FYP\final_project\project\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "D:\University\FYP\final_project\project\Lib\site-packages\django\core\management\__init__.py", line 416, in execute    
    django.setup()
  File "D:\University\FYP\final_project\project\Lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\University\FYP\final_project\project\Lib\site-packages\django\apps\registry.py", line 124, in populate
    app_config.ready()
  File "D:\University\FYP\final_project\project\Lib\site-packages\django\contrib\admin\apps.py", line 27, in ready
    self.module.autodiscover()
  File "D:\University\FYP\final_project\project\Lib\site-packages\django\contrib\admin\__init__.py", line 52, in autodiscover  
    autodiscover_modules("admin", register_to=site)
  File "D:\University\FYP\final_project\project\Lib\site-packages\django\utils\module_loading.py", line 58, in autodiscover_modules
    import_module("%s.%s" % (app_config.name, module_to_search))
  File "C:\Program Files\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "D:\University\FYP\final_project\land_management_system\core\admin.py", line 3, in <module>
    from django.contrib.gis.admin import OSMGeoAdmin
ImportError: cannot import name 'OSMGeoAdmin' from 'django.contrib.gis.admin' (D:\University\FYP\final_project\project\Lib\site-packages\django\contrib\gis\admin\__init__.py)

这是从我的管理代码导入的内容:

from django.contrib import admin
from .models import User, Land, LandTransfers, NFTs, AuthTokens, TaxesFees
from django.contrib.gis.admin import OSMGeoAdmin

我尝试在设置中添加 GEOS 和 GDAL 的自定义路径,但仍然没有帮助:

GDAL_LIBRARY_PATH = r"C:\OSGeo4W\bin\gdal308.dll"
GEOS_LIBRARY_PATH = r"C:\OSGeo4W\bin\geos_c.dll"
python django geospatial gdal geos
1个回答
0
投票

从 Django >= 5.0 开始,该类被删除,如 发行说明中所述:

django.contrib.gis.admin.GeoModelAdmin
OSMGeoAdmin 类已删除

© www.soinside.com 2019 - 2024. All rights reserved.