Unable to login to admin page in Heroku production postgres










1














This app works locally with sqlite. When I push it to production with Heroku, I'm not about to login to the admin page. This is the error I'm getting from debug:




ProgrammingError at /admin/login/ relation "auth_user" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM
"auth_user...




I think I added the correct DATABASE connection string in settings.py (commented out) but that produced the same error. I've run python manage.py makemigrations and migrate. Migrate gave the same error. I found related issues on stack and GitHub but none of them worked. Most of them just said to migrate. Any idea what might be causing the error? TIA



log (last bit)



2018-11-10T02:04:25.402553+00:00 app[web.1]: django.db.utils.ProgrammingError: relation "auth_user" does not exist
2018-11-10T02:04:25.402555+00:00 app[web.1]: LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...
2018-11-10T02:04:25.402556+00:00 app[web.1]: ^
2018-11-10T02:04:25.402557+00:00 app[web.1]:
2018-11-10T02:04:25.403555+00:00 app[web.1]: 10.99.134.157 - - [10/Nov/2018:02:04:25 +0000] "POST /admin/login/?next=/admin/ HTTP/1.1" 500 212013


settings.py



import os
import warnings
from django.utils.translation import ugettext_lazy as _
from os.path import dirname
import django_heroku
import dj_database_url


BASE_DIR = dirname(dirname(dirname(dirname(os.path.abspath(__file__)))))
CONTENT_DIR = os.path.join(BASE_DIR, 'content')

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',

# Vendor apps
'bootstrap4',

# Application apps
'main',
'accounts',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'app.urls'

TEMPLATES = [

'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(CONTENT_DIR, 'templates'),
],
'APP_DIRS': True,
'OPTIONS':
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
,
,
]


DATABASES =
'default':
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),



# DATABASES = {
# 'default':
# 'ENGINE': 'django.db.backends.postgresql',
# 'NAME': '<hide>',
# 'USER': '<hide>',
# 'PASSWORD': '<hide>',
# 'HOST': '<hide>',
# 'PORT': '<hide>',
#

db_from_env = dj_database_url.config(conn_max_age=500, ssl_require=True)
DATABASES['default'].update(db_from_env)



AUTH_PASSWORD_VALIDATORS = [

'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
,

'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
,

'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
,

'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
,
]


django_heroku.settings(locals())


views.py (where the error is hit)



class GuestOnlyView(View):
def dispatch(self, request, *args, **kwargs):
# Redirect to the index page if the user already authenticated
if request.user.is_authenticated:
return redirect(settings.LOGIN_REDIRECT_URL)

return super().dispatch(request, *args, **kwargs)









share|improve this question

















  • 2




    "This app works locally with sqlite." The first thing you should do is make sure that your app runs locally with Postgres. sqlite is incompatible with Heroku.
    – RangerRanger
    Nov 10 at 4:19











  • This is so stupid (I can't believe how many hours I spent trying to figure it out). I didn't have a great reason to use sqlite over postgres, so after reading your comment I downloaded postgres locally. I went through the steps, and everything worked perfectly. So I reset my Heroku database (I didn't have anything in there), migrated, and it worked perfectly. I think it all came down to something being messed up with the migrations. I think the proper solution would have been to fake all migrations.
    – Pawel
    Nov 10 at 5:06















1














This app works locally with sqlite. When I push it to production with Heroku, I'm not about to login to the admin page. This is the error I'm getting from debug:




ProgrammingError at /admin/login/ relation "auth_user" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM
"auth_user...




I think I added the correct DATABASE connection string in settings.py (commented out) but that produced the same error. I've run python manage.py makemigrations and migrate. Migrate gave the same error. I found related issues on stack and GitHub but none of them worked. Most of them just said to migrate. Any idea what might be causing the error? TIA



log (last bit)



2018-11-10T02:04:25.402553+00:00 app[web.1]: django.db.utils.ProgrammingError: relation "auth_user" does not exist
2018-11-10T02:04:25.402555+00:00 app[web.1]: LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...
2018-11-10T02:04:25.402556+00:00 app[web.1]: ^
2018-11-10T02:04:25.402557+00:00 app[web.1]:
2018-11-10T02:04:25.403555+00:00 app[web.1]: 10.99.134.157 - - [10/Nov/2018:02:04:25 +0000] "POST /admin/login/?next=/admin/ HTTP/1.1" 500 212013


settings.py



import os
import warnings
from django.utils.translation import ugettext_lazy as _
from os.path import dirname
import django_heroku
import dj_database_url


BASE_DIR = dirname(dirname(dirname(dirname(os.path.abspath(__file__)))))
CONTENT_DIR = os.path.join(BASE_DIR, 'content')

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',

# Vendor apps
'bootstrap4',

# Application apps
'main',
'accounts',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'app.urls'

TEMPLATES = [

'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(CONTENT_DIR, 'templates'),
],
'APP_DIRS': True,
'OPTIONS':
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
,
,
]


DATABASES =
'default':
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),



# DATABASES = {
# 'default':
# 'ENGINE': 'django.db.backends.postgresql',
# 'NAME': '<hide>',
# 'USER': '<hide>',
# 'PASSWORD': '<hide>',
# 'HOST': '<hide>',
# 'PORT': '<hide>',
#

db_from_env = dj_database_url.config(conn_max_age=500, ssl_require=True)
DATABASES['default'].update(db_from_env)



AUTH_PASSWORD_VALIDATORS = [

'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
,

'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
,

'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
,

'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
,
]


django_heroku.settings(locals())


views.py (where the error is hit)



class GuestOnlyView(View):
def dispatch(self, request, *args, **kwargs):
# Redirect to the index page if the user already authenticated
if request.user.is_authenticated:
return redirect(settings.LOGIN_REDIRECT_URL)

return super().dispatch(request, *args, **kwargs)









share|improve this question

















  • 2




    "This app works locally with sqlite." The first thing you should do is make sure that your app runs locally with Postgres. sqlite is incompatible with Heroku.
    – RangerRanger
    Nov 10 at 4:19











  • This is so stupid (I can't believe how many hours I spent trying to figure it out). I didn't have a great reason to use sqlite over postgres, so after reading your comment I downloaded postgres locally. I went through the steps, and everything worked perfectly. So I reset my Heroku database (I didn't have anything in there), migrated, and it worked perfectly. I think it all came down to something being messed up with the migrations. I think the proper solution would have been to fake all migrations.
    – Pawel
    Nov 10 at 5:06













1












1








1







This app works locally with sqlite. When I push it to production with Heroku, I'm not about to login to the admin page. This is the error I'm getting from debug:




ProgrammingError at /admin/login/ relation "auth_user" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM
"auth_user...




I think I added the correct DATABASE connection string in settings.py (commented out) but that produced the same error. I've run python manage.py makemigrations and migrate. Migrate gave the same error. I found related issues on stack and GitHub but none of them worked. Most of them just said to migrate. Any idea what might be causing the error? TIA



log (last bit)



2018-11-10T02:04:25.402553+00:00 app[web.1]: django.db.utils.ProgrammingError: relation "auth_user" does not exist
2018-11-10T02:04:25.402555+00:00 app[web.1]: LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...
2018-11-10T02:04:25.402556+00:00 app[web.1]: ^
2018-11-10T02:04:25.402557+00:00 app[web.1]:
2018-11-10T02:04:25.403555+00:00 app[web.1]: 10.99.134.157 - - [10/Nov/2018:02:04:25 +0000] "POST /admin/login/?next=/admin/ HTTP/1.1" 500 212013


settings.py



import os
import warnings
from django.utils.translation import ugettext_lazy as _
from os.path import dirname
import django_heroku
import dj_database_url


BASE_DIR = dirname(dirname(dirname(dirname(os.path.abspath(__file__)))))
CONTENT_DIR = os.path.join(BASE_DIR, 'content')

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',

# Vendor apps
'bootstrap4',

# Application apps
'main',
'accounts',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'app.urls'

TEMPLATES = [

'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(CONTENT_DIR, 'templates'),
],
'APP_DIRS': True,
'OPTIONS':
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
,
,
]


DATABASES =
'default':
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),



# DATABASES = {
# 'default':
# 'ENGINE': 'django.db.backends.postgresql',
# 'NAME': '<hide>',
# 'USER': '<hide>',
# 'PASSWORD': '<hide>',
# 'HOST': '<hide>',
# 'PORT': '<hide>',
#

db_from_env = dj_database_url.config(conn_max_age=500, ssl_require=True)
DATABASES['default'].update(db_from_env)



AUTH_PASSWORD_VALIDATORS = [

'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
,

'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
,

'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
,

'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
,
]


django_heroku.settings(locals())


views.py (where the error is hit)



class GuestOnlyView(View):
def dispatch(self, request, *args, **kwargs):
# Redirect to the index page if the user already authenticated
if request.user.is_authenticated:
return redirect(settings.LOGIN_REDIRECT_URL)

return super().dispatch(request, *args, **kwargs)









share|improve this question













This app works locally with sqlite. When I push it to production with Heroku, I'm not about to login to the admin page. This is the error I'm getting from debug:




ProgrammingError at /admin/login/ relation "auth_user" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM
"auth_user...




I think I added the correct DATABASE connection string in settings.py (commented out) but that produced the same error. I've run python manage.py makemigrations and migrate. Migrate gave the same error. I found related issues on stack and GitHub but none of them worked. Most of them just said to migrate. Any idea what might be causing the error? TIA



log (last bit)



2018-11-10T02:04:25.402553+00:00 app[web.1]: django.db.utils.ProgrammingError: relation "auth_user" does not exist
2018-11-10T02:04:25.402555+00:00 app[web.1]: LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...
2018-11-10T02:04:25.402556+00:00 app[web.1]: ^
2018-11-10T02:04:25.402557+00:00 app[web.1]:
2018-11-10T02:04:25.403555+00:00 app[web.1]: 10.99.134.157 - - [10/Nov/2018:02:04:25 +0000] "POST /admin/login/?next=/admin/ HTTP/1.1" 500 212013


settings.py



import os
import warnings
from django.utils.translation import ugettext_lazy as _
from os.path import dirname
import django_heroku
import dj_database_url


BASE_DIR = dirname(dirname(dirname(dirname(os.path.abspath(__file__)))))
CONTENT_DIR = os.path.join(BASE_DIR, 'content')

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',

# Vendor apps
'bootstrap4',

# Application apps
'main',
'accounts',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'app.urls'

TEMPLATES = [

'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(CONTENT_DIR, 'templates'),
],
'APP_DIRS': True,
'OPTIONS':
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
,
,
]


DATABASES =
'default':
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),



# DATABASES = {
# 'default':
# 'ENGINE': 'django.db.backends.postgresql',
# 'NAME': '<hide>',
# 'USER': '<hide>',
# 'PASSWORD': '<hide>',
# 'HOST': '<hide>',
# 'PORT': '<hide>',
#

db_from_env = dj_database_url.config(conn_max_age=500, ssl_require=True)
DATABASES['default'].update(db_from_env)



AUTH_PASSWORD_VALIDATORS = [

'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
,

'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
,

'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
,

'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
,
]


django_heroku.settings(locals())


views.py (where the error is hit)



class GuestOnlyView(View):
def dispatch(self, request, *args, **kwargs):
# Redirect to the index page if the user already authenticated
if request.user.is_authenticated:
return redirect(settings.LOGIN_REDIRECT_URL)

return super().dispatch(request, *args, **kwargs)






django heroku






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 2:14









Pawel

1388




1388







  • 2




    "This app works locally with sqlite." The first thing you should do is make sure that your app runs locally with Postgres. sqlite is incompatible with Heroku.
    – RangerRanger
    Nov 10 at 4:19











  • This is so stupid (I can't believe how many hours I spent trying to figure it out). I didn't have a great reason to use sqlite over postgres, so after reading your comment I downloaded postgres locally. I went through the steps, and everything worked perfectly. So I reset my Heroku database (I didn't have anything in there), migrated, and it worked perfectly. I think it all came down to something being messed up with the migrations. I think the proper solution would have been to fake all migrations.
    – Pawel
    Nov 10 at 5:06












  • 2




    "This app works locally with sqlite." The first thing you should do is make sure that your app runs locally with Postgres. sqlite is incompatible with Heroku.
    – RangerRanger
    Nov 10 at 4:19











  • This is so stupid (I can't believe how many hours I spent trying to figure it out). I didn't have a great reason to use sqlite over postgres, so after reading your comment I downloaded postgres locally. I went through the steps, and everything worked perfectly. So I reset my Heroku database (I didn't have anything in there), migrated, and it worked perfectly. I think it all came down to something being messed up with the migrations. I think the proper solution would have been to fake all migrations.
    – Pawel
    Nov 10 at 5:06







2




2




"This app works locally with sqlite." The first thing you should do is make sure that your app runs locally with Postgres. sqlite is incompatible with Heroku.
– RangerRanger
Nov 10 at 4:19





"This app works locally with sqlite." The first thing you should do is make sure that your app runs locally with Postgres. sqlite is incompatible with Heroku.
– RangerRanger
Nov 10 at 4:19













This is so stupid (I can't believe how many hours I spent trying to figure it out). I didn't have a great reason to use sqlite over postgres, so after reading your comment I downloaded postgres locally. I went through the steps, and everything worked perfectly. So I reset my Heroku database (I didn't have anything in there), migrated, and it worked perfectly. I think it all came down to something being messed up with the migrations. I think the proper solution would have been to fake all migrations.
– Pawel
Nov 10 at 5:06




This is so stupid (I can't believe how many hours I spent trying to figure it out). I didn't have a great reason to use sqlite over postgres, so after reading your comment I downloaded postgres locally. I went through the steps, and everything worked perfectly. So I reset my Heroku database (I didn't have anything in there), migrated, and it worked perfectly. I think it all came down to something being messed up with the migrations. I think the proper solution would have been to fake all migrations.
– Pawel
Nov 10 at 5:06

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235459%2funable-to-login-to-admin-page-in-heroku-production-postgres%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53235459%2funable-to-login-to-admin-page-in-heroku-production-postgres%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)