These days I'm learning Python(2.7)/Django(1.5) via developing a reddit clone. The clone is almost done and works perfectly in my local environment (db = sqlite3). But when I try to host the same thing on Heroku (db = postgres), things go awry.
Specifically, the web app still loads, but the login, logout and the comments part is throwing errors (I'm using django-registrations-redux, django-comments and south).
Since the app is online, you can simply go here to see the error trace:
And all my files, including requirements.txt etc., can be found here: https://github.com/mhb11/unconnectedredditapp
It perplexes me that this thing continues to work perfectly locally, but not on Heroku. I'm assuming I may have fudged up South migrations. However, I've been deleting my Heroku app and setting up new ones all day long. Every time I run the syncdb command on a new app, I get the following error after setting up super user credentials post Django-auth system installation and table creation:
DatabaseError: relation "links_userprofile" does not exist
LINE 1: ...rofile"."user_id", "links_userprofile"."bio" FROM "links_use...
I follow it up with heroku run python2.7 manage.py syncdb --migrate
(i.e. syncdb and migrate together), this time the migration doesn't spout an error. But anyhow, the app nevertheless gives DB errors I pointed out at the start.
I'm thinking I should uninstall South in my local setup, and use good old syncdb for everything.
At this point, there's a ton that could be going wrong with my heroku deployment, so I understand you may not be able to give me a pinpoint solution. But hit me with all ideas you have - I'm open to trying everything, because this thing has now been stuck for me since over 48 hrs. Help!
Note: If you end up checking out the clone (https://salty-ridge-5419.herokuapp.com/), pardon the text labels which aren't in English.
Error trace from running syncdb command after doing git push heroku master
:
(unconnectedreddit)has@has-VirtualBox:~/Desktop/uncreddit$ heroku run python2.7 manage.py syncdb
Running `python2.7 manage.py syncdb` attached to terminal... up, run.8792
CHECKING_HEROKU!
ON_HEROKU!
Syncing...
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table django_comments
Creating table django_comment_flags
Creating table south_migrationhistory
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'u8919'): mhb
Email address: bhs@bhs.com
Password:
Password (again):
DatabaseError: relation "links_userprofile" does not exist
LINE 1: ...rofile"."user_id", "links_userprofile"."bio" FROM "links_use...
The problem was solved via running heroku config:set ON_HEROKU=1
. In my settings.py file, I used sqlite3 locally, but reverted to postgres when on Heroku. Setting ON_HEROKU to 1 before running syncdb, hence, solved the problem for me.