geodjango 同步数据库错误。来自 geodjango 教程

发布于 09-15 19:24 字数 974 浏览 12 评论 0原文

我已经按照geodjango安装(windows XP)和教程做到了完美 我正在运行 django 1.2 当我到达syncdb并运行时,我收到以下内容。

    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured:'django.db.backends.postgis' isn
an available database backend.
Try using django.db.backends.XXX, where XXX is one of:
    'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3
Error was: No module named postgis.base

我尝试更改为“django.db.backends.postgresql_psycopg2”作为替代方案 但后来我收到了这样的回复:

AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'

当我尝试 posgresql:

    **raise ImproperlyConfigured("Error loading psycopg module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg module: No mo
dule named psycopg**

它不应该是我成功下载并安装的 postgis 吗?为什么它不工作?我是新人,我正在努力学习,因此我们将不胜感激任何帮助。

I have followed the geodjango installation(windows XP) and tutorial to perfection
I am running django 1.2
When I get to syncdb and run I receive the following.

    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured:'django.db.backends.postgis' isn
an available database backend.
Try using django.db.backends.XXX, where XXX is one of:
    'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3
Error was: No module named postgis.base

I tried changing to 'django.db.backends.postgresql_psycopg2' as an alternative
But then I receive this response:

AttributeError: 'DatabaseOperations' object has no attribute 'geo_db_type'

When I try posgresql:

    **raise ImproperlyConfigured("Error loading psycopg module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg module: No mo
dule named psycopg**

Is it not supposed to be postgis which I successful downloaded and installed? why isn’t it working? I am new and I am trying to learn so any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

莫相离2024-09-22 19:24:03

问题是,在 settings.py

'django.db.backends.postgis'

应该可以

django.contrib.gis.db.backends.postgis

做到这一点。

The problem is, in settings.py

'django.db.backends.postgis'

it is supposed to be

django.contrib.gis.db.backends.postgis

that should do it.

旧故2024-09-22 19:24:03

在按照 geodjango 站点上的说明并使用 Homebrew 安装软件包后,我在 Mac OS X 10.6 上遇到了同样的错误。显然,Geodjango 文档给出了一些关于如何安装它的不正确/过时的说明。为了使 Geodjango 工作,我遵循了以下几个步骤:

  1. 现在,GeoDjango 1.4 与 PostGIS 2.0 不能很好地配合(这是我按照 GeoDjango 文档中的说明安装的 Homebrew 版本)。所以,我需要安装 PostGIS 1.5。我使用以下终端命令执行此操作(为此,您必须安装 Homebrew):

    brew tap 自制软件/版本
    酿造安装postgis15
    brew untap 自制程序/版本
    
  2. PostGIS 1.5 与 PostGreSQL 9.2(这是我按照 Geodjango 文档的说明安装的 Homebrew 版本)配合得不好。所以,我安装了 PostGreSQL 9.1。我完全忘记了安装 PostGreSQL 9.1 时使用的 Homebrew 命令,但它们应该与上一步类似。

  3. 就我而言,前面的步骤不足以让 Geodjango 运行。当我再次尝试在 Django 中运行“syncdb”时,我在终端中发现了一个新错误:

    django.core.exceptions.ImproperlyConfigured:加载 psycopg 模块时出错: 
    没有名为 psycopg 的模块 
    
  4. 我最初以为我的 psycopg2 和 PostgreSQL9.1 副本不在我的 PYHTONPATH 上,所以我添加了它们。我还尝试确保 django 运行的是 PostgreSQL 9.1 而不是 9.2。我使用了“initdb /usr/local/var/postgres”。

  5. 然后我需要做一些数据库配置。我在 PostGIS 中设置了一个模板,并为数据库设置了一个“角色”(/用户)。为此,我按照 Geodjango 文档中的说明进行操作。我收到了很多错误,但通过 Google 搜索并很容易找到解决方案。

  6. 然后 GeoDjango 开始正常工作了!

该来源是我发现的最有用的来源,并链接到其他有用的网址,这些网址更详细地介绍了其中一些问题: http://pragmaticstartup.wordpress.com/2012/09/26/installing-django-postgis-postgres-on-os-x -版本地狱/

I experienced this same error on Mac OS X 10.6 after I followed the instructions on the geodjango site and installed packages using Homebrew. Apparently, the Geodjango documentation gave some incorrect/outdated instructions about how to install it. To make Geodjango work, I followed several steps:

  1. Right now, GeoDjango 1.4 does not play nice with PostGIS 2.0 (which is the version Homebrew installed when I followed the instructions in the GeoDjango documentation). So, I needed to install PostGIS 1.5. I did this using the following Terminal commands (for this to work, you must have Homebrew installed):

    brew tap homebrew/versions
    brew install postgis15
    brew untap homebrew/versions
    
  2. PostGIS 1.5 doesn't play nice with PostGreSQL 9.2 (which is the version Homebrew installed when I followed the Geodjango documentation's instructions). So, I installed PostGreSQL 9.1. I forget exactly what Homebrew commands I used to install PostGreSQL 9.1, but they should be similar to the previous step.

  3. In my case the prior steps weren't sufficient to get Geodjango operational. When I tried to run 'syncdb' in Django again, I discovered a new error in Terminal:

    django.core.exceptions.ImproperlyConfigured: Error loading psycopg module: 
    No module named psycopg 
    
  4. I initially thought my copy of psycopg2 and PostgreSQL9.1 were not on my PYHTONPATH, so I added them. I also fiddled around to make sure django was running PostgreSQL 9.1 instead of 9.2. I used 'initdb /usr/local/var/postgres'.

  5. Then I needed to do some database configuration. I set up a template in PostGIS and set up a "role" (/user) for the database. To do this, I followed the instructions in the Geodjango documentation. I received numerous errors, but Googled them and found solutions pretty easily.

  6. Then GeoDjango started working properly!

This source was the most helpful one I found and links to other helpful urls that cover some of these issues in more detail: http://pragmaticstartup.wordpress.com/2012/09/26/installing-django-postgis-postgres-on-os-x-version-hell/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文