Django Admin does not work after deployment Heroku - django

After deploying my application the admin of the website does not work. I am able to use the website, create an account and do all the crud, but the admin does not work.
1 - I created the superuser with
python manage.py createsuperuser
2 - I deployed and tried to access the admin
https://djangotodowoo.herokuapp.com/admin
Although, every time that I try to access this page it redirects to:
https://djangotodowoo.herokuapp.com/admin/login/?next=/admin/
I am not sure if that's the problem, but it's a hint at least.
This is happening because I have on my settings.py the following line
LOGIN_URL = '/login'
That checks if someone is trying to access a page without login and redirects to the login page.
I am not sure what the problem actually is, any ideas on how to solve the issue?
Thank you very much folks!

I found out that everything was working locally, the reason I was not able to log into the admin with my admin account is that I have to create a superuser on the Heroku side as well.
The solution was:
Create Heroku Super User
heroku run python manage.py createsuperuser

Related

Cannot login to django admin page after render deployment

I'm trying to deploy a simple django application (SQLite3) to render but I can't log in to the admin page even with valid superuser credentials. I could authenticate locally, but not while on the render deployed version.
Your help is much appreciated!
Try running python manage.py createsuperuser in the Render Shell.
Documentation on creating a Django admin account on Render deployments.
As a substitute to running python manage.py createsuperuser on Render Shell, you can do a quick deployment with python manage.py createsuperuser --no-input on your build script and have environment variables such as DJANGO_SUPERUSER_USERNAME set. You then have to remove this hack for later builds.
See https://stackoverflow.com/a/59467533/4932353 for more information.

Wagtail superuser unable to log in to CMS

I'm new to Wagtail and django. I've completed the https://learnwagtail.com/wagtail-for-beginners/ course and managed to get my site up and running on Digital ocean, however I'm unable to login to the admin area. I have tried using the superuser credentials that were used locally. I have also tried multiple times to create a new superuser with:
python manage.py createsuperuser
and while the process appears to work successfully in the terminal (I'm logged in via SSH to my DO droplet), I continually receive the 'Your username and password didn't match. Please try again.' message when attempting to log in with the newly created username and password. If I use the shell to check users I can see my newly created user exists. I have also tried using
python manage.py changepassword myusername
to change the password on the previously created superusers, but again, while the process appears to work successfully in the terminal I continue to receive the error message when attempting to log in. Can anyone point me in the right direction as to what I might be missing or doing wrong here? And / or how I might best debug the issue? Thanks in advance!
You might need to set up a Site that matches the domain on which you're accessing your site. In the command line, try this:
import wagtail.core.models.sites
s=Site.objects.last()
s.hostname='yourdomain'
s.site_name='verbose site name'
s.is_default_site=True
s.save()
If you don't already have a site in the database (or just want to add another one), then do s=Site.objects.create() instead of Site.objects.last()place the three properties into thecreate` statement as keywords.
I needed to make sure my manage.py commands were picking up my production settings. So running:
DJANGO_SETTINGS_MODULE=mysite.settings.production ./manage.py createsuperuser
and NOT:
python manage.py createsuperuser was the solution.

Django migrate - django.db.utils.OperationalError: attempt to write a readonly database

I have read the answers to similar (same) questions and the solutions have not worked for me.
I have a django application running with Apache2 webserver, and the user is set to the default www-data. Currently, www-data has full access to the db. This was working fine until couple of commits ago and I'm clueless at exactly what went wrong (Since I didn't touch the database at all during the period). Another thing to note is that makemigrations work perfectly fine, and the database is editable without errors in the django admin console.
Currently, this is my permission settings for the db:
The error message is:
Any help would be appreciated thanks!

django postgres integration error, no such table - auth user

After updating the django settings.py default database to correct values.
i am able to run makemigrations and migrate command and also create super user. but when i login to the admin it gives me error of “no such table - auth user, OPERATIONAL ERROR”.
I noticed that even if i delete db.sqlite3 file, it comes back when i try to login, i think django looks for table in db.sqlite3 and not postgres.
why db.sqlite3 file re appear after deleting ?
how do i correctly configure my settings.py ?
i am integration using digitalocean managed database services with django installed in one droplet, i have integrated both preciously without error but i installed postgres, this is the first time using managed database service.
Thanks
It seems that your django settings are still pointing to the SQlite database.
Did you reload your WSGI process ? If not, the old SQlite settings are still used in memory.

Django-nonrel cannot login into the admin interface

I have a Django app which I am trying to get to Django-nonrel so that I can get it on GAE. The problem though is that numerous times have I tried creating superuser for the admin interface still when I do syncdb, it shows me:
You just installed Django's auth system, which means you don't have
any superusers defined.
everytime.Also, I am never able to login into my admin interface by the created superuser. Also, when I do this:
python manage.py shell
>>> from django.contrib.auth.models import User
>>> User.objects.all()
[]
SO no users are created it seems. I tried to look for the solution and and had a look at a few questions like these:
django-nonrel and the admin page
and a few others. Didn't help either. I would like to mention that I am using zip downloaded version of django-nonrel 1.6 and djangoappengine by copying them in my project directory
I also tried creating a user by the python manage.py shell and granting it is_staff= True.
The user is now being shown in the User.objects.all() but I cannot still not login by this user.