0

When I run my django project on my local pc, it works perfectly fine and I can sign up/log in/log out on my site. When I deploy it to Heroku, it doesn't work anymore, giving me the following error:

OperationalError at /login/

no such table: auth_user

I know this question exists, and I've already tried all the solutions, but it still hasn't worked. I've done migrate and makemigrations on both the python and heroku side, along with the commit command at different intervals. I also don't even have the usercreateform, and OP's error for that question appeared on their local pc, not just Heroku. I also tried creating a super user, which I could on my local pc, but not on Heroku.

If it helps, my procfile is:

web: gunicorn django_project.wsgi --log-file - 

I had a hard time determining my procfile, so maybe that's the problem? The django_project part is just the name of the folder that includes settings.py and wsgi.py.

Forms.py:

class NewCommentForm(forms.ModelForm):
    class Meta:
        model = Comment
        fields = ['content']

class NewMessageForms(forms.ModelForm):
    class Meta:
        model = Message
        fields = ['content','reciever']

If you want to see my site in action, go to newsment.herokuapp.com and try to sign up or login (it will give the error).

Rebecca
  • 11
  • 1
  • 1
    please run migration on heroku – Kiran Aug 10 '21 at 17:28
  • 1
    Run ```python manage.py migrate``` on Heroku – Ram Aug 10 '21 at 17:30
  • Maybe django thinks the migrations with auth_user table are already applied? if your'e using mysql I recommend you to delete your database before attempting to migrate.... for sqlite, deleting your db.sqlite file will do. (that's if you're starting and don't have important data to lose) – Julio González Aug 10 '21 at 17:37
  • @ram I already did – Rebecca Aug 10 '21 at 17:57
  • @KiranChauhan I already did – Rebecca Aug 10 '21 at 17:57
  • @JulioGonzález Thank you for your response! I deleted the db.sqlite file, ran migrations and makemigrations again, pushed the changes to heroku... but it still gave me the same error:( – Rebecca Aug 10 '21 at 18:03
  • You can't use SQLite with Heroku due to its ephemeral filesystem. Please see the linked duplicates. – ChrisGPT was on strike Aug 10 '21 at 21:04
  • @Chris ah, thank you, I'll try that. Do you know why this one doesn't work while this one https://github.com/redianmarku/Django-Twitter-Clone works? They both use sqlite, and it was the program I based mine off of (but after I changed it, it doesn't work anymore) – Rebecca Bibye Aug 11 '21 at 01:09
  • @Chris also is there an alternative to Heroku that does accept sqlite? that's also dynamic (not netlify) – Rebecca Bibye Aug 11 '21 at 01:10
  • @Chris also how is this https://learning-log.herokuapp.com/ (from Al Sweigart's book) possible if heroku doesn't accept sqlite? So basically, why me? – Rebecca Bibye Aug 11 '21 at 01:16
  • That hosted "learning-log" site tells us nothing about how it is built. It's irrelevant. And the Twitter clone uses a MySQL driver, so it probably uses MySQL. We're not here to read thousands of lines of code and explain how they work. Please take _five minutes_ and search "heroku sqlite" on your favourite search engine. There are countless resources explaining this, and it is your responsibility to [do a bit of work](https://meta.stackoverflow.com/q/261592/354577). Don't ask "why me?" and feel sorry for yourself. _Learn_. – ChrisGPT was on strike Aug 11 '21 at 01:22
  • @Chris ...sorry, I promise this is the last question: Why does the Twitter clone have: "web: gunicorn Django-Twitter-Clone.wsgi --log-file -"? There's clearly not a folder marked 'django-twitter-clone', so how does it possibly work? Shouldn't it be 'django_project.wsgi" instead? Thanks – Rebecca Bibye Aug 11 '21 at 01:47
  • That's a random person's random codebase shared on the Internet. I have no reason to believe it's correct, and I'm not going to dig into it to figure out how it works (or doesn't). Yes, it should probably be `django_project.wsgi`, but that's a question _for the author of that codebase_, not us. Submit an issue and ask them. – ChrisGPT was on strike Aug 11 '21 at 01:52
  • @Chris ah, thanks, I just thought you knew why. – Rebecca Bibye Aug 11 '21 at 01:55
  • Are you using multiple accounts ([Rebecca](https://stackoverflow.com/users/16203021/rebecca) and [Rebecca Bibye](https://stackoverflow.com/users/13985847/rebecca-bibye))? That's not strictly against the rules, but [it is discouraged](https://meta.stackexchange.com/q/35593/248627). It's disconcerting to talk to multiple accounts belonging to the same person in one thread. – ChrisGPT was on strike Aug 11 '21 at 01:55
  • @Chris haha I read your link and it said it's fine as long as I'm not voting for my other account (which I'm not, obviously) – Rebecca Bibye Aug 11 '21 at 01:58

0 Answers0