简体   繁体   English

Django 1.6 + postgres 9.3:我想要在本地主机上进行开发的最简单的数据库配置

[英]Django 1.6 + postgres 9.3: I want the simplest possible database configuration for development on localhost

So I have this in my django settings.py file: 所以我在django settings.py文件中有这个:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'myproj_db',
        'USER': 'myproj_user',
        'PASSWORD': 'myproj_pw',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

If I go to my terminal prompt and run psql -d myproj_db -U myproj_user -h localhost -p 5432 I get the following output: 如果我进入终端提示符并运行psql -d myproj_db -U myproj_user -h localhost -p 5432得到以下输出:

psql (9.3.2)
Type "help" for help.

myproj_db=> \l
                                List of databases
    Name    | Owner | Encoding |   Collate   |    Ctype    |  Access privileges
------------+-------+----------+-------------+-------------+----------------------
 jon        | jon   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 postgres   | jon   | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0  | jon   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/jon              +
            |       |          |             |             | jon=CTc/jon
 template1  | jon   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/jon              +
            |       |          |             |             | jon=CTc/jon
 myproj_db  | jon   | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/jon             +
            |       |          |             |             | jon=CTc/jon         +
            |       |          |             |             | myproj_user=CTc/jon
(5 rows)

myproj_db->

I then run my usual sequence for rebuilding my django database: 然后,我按照通常的顺序重建django数据库:

PROMPT> ./manage.py sqlclear data | ./manage.py dbshell
PROMPT> ./manage.py sqlall data | ./manage.py dbshell
PROMPT> ./manage.py flush

and I get the following error: 我收到以下错误:

CommandError: Database myproj_db couldn't be flushed. Possible reasons:
  * The database isn't running or isn't configured correctly.
  * At least one of the expected database tables doesn't exist.
  * The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
The full error: relation "django_admin_log" does not exist

This is the first I have ever heard of django_admin_log. 这是我第一次听说django_admin_log。 Have I overlooked something? 我忽略了什么吗?

我需要运行python manage.py syncdb -此命令构建了django_admin_log数据库表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM