Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Summary of what steps explained above (for Mac Users):
- Create a Postgres database in PgAdmin3. We need three fields for the next step: database-name, username, password of Postgresql. username is the owner and password is the owner's passowrd. You may want to keep it simple and use postgres/ postgres for that.
- In your root folder, do $ vi $VIRTUAL_ENV/bin/postactivate and add this:
- export DATABASE_NAME='database-name'
- export DATABASE_USER='username'
- export DATABASE_PASSWORD='password'
- Now do $ vi $VIRTUAL_ENV/bin/predeactivate and add:
- unset DATABASE_NAME
- unset DATABASE_USER
- unset DATABASE_PASSWORD
- Restart (reactivate) your virtual env by deactivate and workon commands.
- To see the Postgres integration, do:
- python3 manage.py check and then python3 manage.py migrate
- You will most likely have gotten an error in step 5, if the stack trace mentions postgis then complete the next section and then retry step 5. Remember if you need help, ask for it.
- Cleaning up your Postgresql DB
- Sometimes you might run into database errors, e.g. when a certain column in a table doesn't exist and python3 manage.py migrate doesn't seem to fix it.
- What you can try is to drop your database:
- sudo -u postgres psql
- drop database <your_database_name>;
- create database <your_database_name> with owner <user_you_use_in_django>;
- \q
- and run python3 manage.py migrate & python3 manage.py runserver again.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement