Advertisement
Guest User

Untitled

a guest
Oct 11th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. Summary of what steps explained above (for Mac Users):
  2.  
  3. 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.
  4. In your root folder, do $ vi $VIRTUAL_ENV/bin/postactivate and add this:
  5. export DATABASE_NAME='database-name'
  6. export DATABASE_USER='username'
  7. export DATABASE_PASSWORD='password'
  8. Now do $ vi $VIRTUAL_ENV/bin/predeactivate and add:
  9. unset DATABASE_NAME
  10. unset DATABASE_USER
  11. unset DATABASE_PASSWORD
  12. Restart (reactivate) your virtual env by deactivate and workon commands.
  13.  
  14. To see the Postgres integration, do:
  15.  
  16. python3 manage.py check and then python3 manage.py migrate
  17.  
  18. 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.
  19. Cleaning up your Postgresql DB
  20.  
  21. 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.
  22.  
  23. What you can try is to drop your database:
  24.  
  25. sudo -u postgres psql
  26. drop database <your_database_name>;
  27. create database <your_database_name> with owner <user_you_use_in_django>;
  28. \q
  29. and run python3 manage.py migrate & python3 manage.py runserver again.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement