开发者

Database password requested when running "manage.py test"

When I try to run

manage.py test

a database password prompt shows.

Previously, tests would run without me having to enter the db password manaually. I just updated my database to postgres 8.4. I assume it's some setting I'm forgetting.

How can I configure it to run tests without asking for the password?

Additional Info:

I created the database with the user 'postgres', but am accessing in django with the user, 'postgis'. I checked the permissions of these users, and they are the same.

When running the test the db and tables get created fine (no password requested). It's only when it installs 'Custom SQL' that the password is requested.

RESOLUTION

As Carl pointed out the ~/.pgpass file [*nix] and %A开发者_运维问答PPDATA%\postgresql\pgpass.conf (where %APPDATA% refers to the Application Data subdirectory in the user's profile) [windows] allows you to configure databases so you don't need to enter a password each time.

See the postgres documentation: The Password File

I checked my configuration and it looks like this file was/is auto-created. I updated my password file and now django tests run without the need to manually enter a password on each custom sql installation.


Django tests use a different database; your DATABASE_NAME setting with "_test" appended. My first guess would be that somewhere in your Postgres authentication config (either in pg_hba.conf or in a ~/.pgpass file), you are allowing access to DATABASE_NAME with no password, but you don't have the same config for DATABASE_NAME_test.


I assume it's some setting I'm forgetting.

Not trying to make a fool out of you, but sometimes simple solutions are overlooked: Did you set the DATABASE_PASSWORD setting in your settings.py file?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜