Programming Error in deploying Django website on Heroku - django

I am learning Django and wanted to deploy the app on Heroku. upon following the Heroku documentation on deploying the app to the platform. It is throwing errors.
I have 2 apps in the project:
blog (for writing the blogs)
userAuthentication (user auth)
Please help!
ERROR on Heroku deployed app:
ProgrammingError at /
relation "blog_categories" does not exist
LINE 1: ...categories"."name", "blog_categories"."name" FROM "blog_cate...
^
Request Method: GET
Request URL: https://sciencecreed.herokuapp.com/
Django Version: 3.2
Exception Type: ProgrammingError
Exception Value:
relation "blog_categories" does not exist
LINE 1: ...categories"."name", "blog_categories"."name" FROM "blog_cate...
^
Exception Location: /app/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py, line 84, in _execute
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.9.4
Python Path:
['/app/.heroku/python/bin',
'/app',
'/app/.heroku/python/lib/python39.zip',
'/app/.heroku/python/lib/python3.9',
'/app/.heroku/python/lib/python3.9/lib-dynload',
'/app/.heroku/python/lib/python3.9/site-packages']
Server time: Thu, 29 Apr 2021 21:36:58 +0000
ERROR on executing "heroku logs"
The migrations work fine when running them locally with sqlite3 database but not on Heroku with PostgreSQL.
I tried running python manage.py makemigrations & python manage.py migrate on Heroku but no luck.
You can visit https://sciencecreed.herokuapp.com/ for the complete info of the error.

Related

Deployed django app error: Relation does not exist

I deployed a django app using a postresql database with Heroku.
The app works perfectly on my local machine but when I want to create a user or to login using the deployed app, I run into the following error:
ProgrammingError at /register/
relation "register_user" does not exist
LINE 1: SELECT (1) AS "a" FROM "register_user" WHERE "register_user"...
^
Request Method: POST
Request URL: https://the-gecko.herokuapp.com/register/
Django Version: 4.0.3
Exception Type: ProgrammingError
Exception Value:
relation "register_user" does not exist
LINE 1: SELECT (1) AS "a" FROM "register_user" WHERE "register_user"...
^
Exception Location: /app/.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py, line 89, in _execute
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.9.10
Python Path:
['/app/.heroku/python/bin',
'/app',
'/app/.heroku/python/lib/python39.zip',
'/app/.heroku/python/lib/python3.9',
'/app/.heroku/python/lib/python3.9/lib-dynload',
'/app/.heroku/python/lib/python3.9/site-packages']
Server time: Mon, 21 Mar 2022 19:59:58 +0000
I believe this error has something do to with my postgres database, but I don't know what relevant code to share in that case.
Please, let me know if you have any idea how to solve that issue.

getting error when trying to add object in django admin

error page
Trace:
OperationalError at /admin/jobs/job/add/
no such table: main.auth_user__old
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/jobs/job/add/
Django Version: 2.0.2
Exception Type: OperationalError
Exception Value:
no such table: main.auth_user__old
Exception Location: C:\Users\codering\Desktop\myenv\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 303
Python Executable: C:\Users\codering\Desktop\myenv\Scripts\python.exe
Python Version: 3.8.0
Python Path:
['C:\\Users\\codering\\Desktop\\portfolio',
'C:\\Users\\codering\\Desktop\\myenv\\Scripts\\python38.zip',
'C:\\Users\\codering\\Desktop\\myenv\\DLLs',
'C:\\Users\\codering\\Desktop\\myenv\\lib',
'C:\\Users\\codering\\Desktop\\myenv\\Scripts',
'c:\\users\\codering\\appdata\\local\\programs\\python\\python38\\Lib',
'c:\\users\\codering\\appdata\\local\\programs\\python\\python38\\DLLs',
'C:\\Users\\codering\\Desktop\\myenv',
'C:\\Users\\codering\\Desktop\\myenv\\lib\\site-packages']
Server time: Wed, 20 Nov 2019 10:45:27 +0000
This page is opening when i am trying to add an object, can anyone help?
Try running
python manage.py makemigrations
python manage.py migrate
From command line

Django error, constantly faced with the same server error even if I start an entirely new application and run it

OperationalError at /
no such table: core_document
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 2.1.4
Exception Type: OperationalError
Exception Value:
no such table: core_document
Exception Location: C:\Python37-32\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 296
Python Executable: C:\Python37-32\python.exe
Python Version: 3.7.1
Python Path:
['E:\Django\Dec19\simple-file-upload-master',
'C:\Python37-32\python37.zip',
'C:\Python37-32\DLLs',
'C:\Python37-32\lib',
'C:\Python37-32',
'C:\Python37-32\lib\site-packages']
Server time: Wed, 19 Dec 2018 04:22:57 +0000
Try to run migrations:
python manage.py makemigrations
python manage.py migrate
The first line of the error explains the core issue:
OperationalError at / no such table: core_document
The table which is being referenced doesn't exist. This usually happens when migrations haven't successfully run. To begin troubleshooting (and to possibly fix the problem entirely), run the Django migrations:
python manage.py makemigrations
python manage.py migrate

Django: Error while installing "Django Registration Redux"

I am trying to install "Django Registration Redux".
I followed every step in the official website to install.
When I am installing django.contrib.sites, the admin doesn't work, and when I comment this the admin starts working but registration does not work in either way.
It gives the error as:
DoesNotExist at /accounts/login/
Site matching query does not exist.
Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/login/
Django Version: 1.9
Exception Type: DoesNotExist
Exception Value:
Site matching query does not exist.
Exception Location: c:\Python27\lib\site-packages\django\db\models\query.py in get, line 387
Python Executable: c:\Python27\python.exe
Python Version: 2.7.11
Python Path:
['E:\\myproject\\mysite',
'C:\\Windows\\SYSTEM32\\python27.zip',
'c:\\Python27\\DLLs',
'c:\\Python27\\lib',
'c:\\Python27\\lib\\plat-win',
'c:\\Python27\\lib\\lib-tk',
'c:\\Python27',
'c:\\Python27\\lib\\site-packages']
Server time: Tue, 24 May 2016 13:26:56 +0000
It sounds like you haven't followed the instructions to enable the sites framework.
After adding django.contrib.sites to INSTALLED_APPS, you need to set SITE_ID = 1 in your settings, then run the migrate command.

Migrate databases from local django to heroku

I have an application in Django that I deploy in heroku.
The deploy works well, but my model's database was not migrate.
After the deploy, I run again localy:
python manage.py makemigrations
python manage.py migrate
After, I do:
heroku run python manage.py makemigrations
heroku run python manage.py migrate
And after I run the server and wait it works well:
heroku run python manage.py runserver
I have 3 models:
cliente, categoria, produto
produto has a ForeignKey to categoria. So, localy, I have 3 databases:
produtos_produto, produtos_categoria, cliente.
I use PostgreSQL as database localy and in heroku.
But in heroku, I don't have any of this databases.
When I run the server, in browser I have the following answer:
ProgrammingError at /
relation "produtos_categoria" does not exist
LINE 1: ...ia"."descricao", "produtos_categoria"."logo" FROM "produtos_...
^
Request Method: GET
Request URL: http://redewebsite.herokuapp.com/
Django Version: 1.9.2
Exception Type: ProgrammingError
Exception Value:
relation "produtos_categoria" does not exist
LINE 1: ...ia"."descricao", "produtos_categoria"."logo" FROM "produtos_...
^
Exception Location: /app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py in execute, line 64
Python Executable: /app/.heroku/python/bin/python
Python Version: 2.7.11
Python Path:
['/app',
'/app/.heroku/python/bin',
'/app/.heroku/python/lib/python2.7/site-packages/setuptools-19.6-py2.7.egg',
'/app/.heroku/python/lib/python2.7/site-packages/pip-8.0.2-py2.7.egg',
'/app',
'/app/.heroku/python/lib/python27.zip',
'/app/.heroku/python/lib/python2.7',
'/app/.heroku/python/lib/python2.7/plat-linux2',
'/app/.heroku/python/lib/python2.7/lib-tk',
'/app/.heroku/python/lib/python2.7/lib-old',
'/app/.heroku/python/lib/python2.7/lib-dynload',
'/app/.heroku/python/lib/python2.7/site-packages']
Server time: Sex, 4 Mar 2016 17:50:43 +0000
You must run makemigrations locally, then commit those generated migration files to git. Heroku will run then automatically when you deploy.