安装Nadine(PostgreSQL)执行./manage.py migrate时遇数据库ENGINE配置错误
Looks like you’re hitting a classic Django database configuration snag—your settings.py file isn’t specifying the correct database engine for PostgreSQL, which is why the migrate command is throwing that error. Let’s work through this step by step:
1. Locate your Nadine project’s settings.py file
You’ll find this file either in the root directory of your Nadine installation or inside a subfolder with the same name as the project (e.g., nadine/nadine/settings.py).
2. Update the DATABASES configuration block
Find the DATABASES dictionary in your settings.py and ensure it includes the PostgreSQL-specific ENGINE value, plus all required connection details. Here’s a working example tailored for PostgreSQL:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', # Use this for Django 2.0+; older versions use 'django.db.backends.postgresql_psycopg2' 'NAME': 'your_nadine_database_name', # Replace with your actual PostgreSQL database name 'USER': 'your_postgresql_username', # Replace with your DB username 'PASSWORD': 'your_postgresql_password', # Replace with your DB password 'HOST': 'localhost', # Use 'localhost' if PostgreSQL runs locally; adjust for remote servers 'PORT': '5432', # Default PostgreSQL port—change only if you modified it } }
3. Install the PostgreSQL adapter for Django
Before running migrations, make sure you have the required adapter installed. Run this command in your virtual environment:
pip install psycopg2-binary
(Note: psycopg2-binary is easier for development setups. For production, use the standard psycopg2 package, which requires system-level PostgreSQL libraries.)
4. Verify your configuration and run migrations
First, check if your settings are valid with:
./manage.py check
If no errors appear, you can now run the migration command successfully:
./manage.py migrate
Quick Troubleshooting Tips
- Double-check that your PostgreSQL server is running (use
sudo systemctl start postgresqlon Linux, or verify the service in Windows/macOS). - Ensure the database name you specified exists in PostgreSQL—create it via command line with
createdb your_nadine_database_nameif needed. - Confirm your PostgreSQL user has access permissions to the database: run
GRANT ALL PRIVILEGES ON DATABASE your_nadine_database_name TO your_postgresql_username;in the PostgreSQL shell if required.
内容的提问来源于stack exchange,提问作者Nitish awasthi

