简体   繁体   中英

Start mezzanine project with custom database

I'm trying to start up a mezzanine project with my own database, however when i create the database and migrate after starting a new project, the database remains empty. This is what I do:

1) In PGADMIN 4, I create a new database with the name 'mydatabase' and the user 'myuser' and password 'mypassword'

2) I start a new mezzanine project with:

mezzanine-project testproject

3) I change my database in settings.py to:

DATABASES = {
    "default": {
        # Add "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
        "ENGINE": "django.db.backends.postgresql_psycopg2",
        # DB name or path to database file if using sqlite3.
        "NAME": "mydatabase",
        # Not used with sqlite3.
        "USER": "myuser",
        # Not used with sqlite3.
        "PASSWORD": "mypassword",
        # Set to empty string for localhost. Not used with sqlite3.
        "HOST": "localhost",
        # Set to empty string for default. Not used with sqlite3.
        "PORT": "5432",
    }
}

4) Finally, I run:

python manage.py migrate

Everything runs fine - but the database I created in PGADMIN 4 remains empty (no new tables), even after refreshing and restarting.

So, where does this database get created?? I'm specifying the database as a postgres database, and I don't have any other instances of postgres on the computer? How do I get the tables to populate in my mydatabase database?

Thanks in advance!

Dug around some more and found a file called "local_settings.py" under my app folder, which I was unaware of. The database settings for local development are stored here and changing the database settings to what I wanted fixed the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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