8

I am trying to login to admin url of the Django post creating superuser through command prompt. After i clicked log in button i am getting "Python has stopped working".

Python Ver: 3.7.0 Django Ver: 3.0

  • Step 1: Created website using django-admin command

  • Step 2: Using runserver command verified Django Default home page is loading

  • Step 3: Tried admin/ post creating super admin users.

  • Step 4: Post Login button click, "Python Stopped working" error is displayed.


What I tried to solve this issue without any success

  1. Verified through shell my created user is active, superadmin, is_staff and all are true
    from django.contrib.auth import authenticate

    u = authenticate(username="username", password="password")
  1. Tried adding and removing SESSION_COOKIE_SECURE = False in settings.py

  2. Verifed ALLOWED_HOSTS = [] in settings.py

    What should I do to see the admin page?

Community
  • 1
  • 1
useruser00
  • 157
  • 1
  • 2
  • 14
  • 1
    ALLOWED_HOSTS should be `['*']` to allow access from everywhere. But I doubt that caused "Python stopped working" error. – Shiva Dec 06 '19 at 09:17
  • do you see any errors in the python service that is running django? – Simas Joneliunas Dec 06 '19 at 09:24
  • @SimasJoneliunas i got the below trace [06/Dec/2019 01:35:08] "POST /admin/login/?next=/admin/ HTTP/1.1" 302 0 – useruser00 Dec 06 '19 at 09:36
  • if you open the debug window (for Firefox F12 -> network), to what url does your server redirect any get request after that post? – gelonida Dec 06 '19 at 11:07
  • @useruser00 I am facing the same problem right now. Every time I log in to admin url python stops working. Even the apps I was working on two days ago are not working now. Have you figured out a solution yet? – Hajar Dec 08 '19 at 09:25
  • 1
    Hey! So I have uninstalled python and reinstalled it (version 3.8) and thankfully everything is working again. – Hajar Dec 08 '19 at 13:21
  • @gelonida "POST /admin/login/?next=/admin/ HTTP/1.1" 302 0 this url is getting displayed in the command prompt. – useruser00 Dec 09 '19 at 09:02
  • @Hajar No luck with the issue.... still having same problem :( – useruser00 Dec 09 '19 at 09:11
  • I know how frustrating it's so I really hope you figure out a solution soon. – Hajar Dec 09 '19 at 13:55
  • @Hajar Till yesterday i tried with Python 3.7.0, i upgraded python to 3.7.3 and the admin page opens smoothly as expected. Not sure any issue with 3.7.0 for django... – useruser00 Dec 10 '19 at 04:15
  • That's great! And yes, I think it has something to do with python 3.7.0 because when I used version 3.8 of python the admin page opened with me as well. – Hajar Dec 10 '19 at 13:10

5 Answers5

6

I had the same problem with python 3.7.0 and Django 3.0 I've solved it by upgrading the python to Python 3.7.6

brew upgrade python3

Then I faced some issues with links and venv and I had to reinstall my venv and Django. So, I hope it helps someone.

Tim Titov
  • 76
  • 3
2

I got the same issue with Python 3.7.0 as well. Upgrading to Python 3.8.0 solves this.

waitingkuo
  • 89,478
  • 28
  • 112
  • 118
1

I had also facing the same issue i upgrade my python but problem is not with python it is occur by virtual environment. upgrade your virtual environment by running following command python -m venv --upgrade ./myvenv

Seth
  • 331
  • 4
  • 9
1

Same issue with Python 3.7.0 > fixed with Python 3.7.8

xco
  • 51
  • 2
0

I had the same problem. But I was using anaconda bundle. It doesn't allow you to update your python packages to minor versions like "3.7.X" or "3.8.X". So, I uninstalled the existing bundle and reinstalled it which comes with a 3.7.6 version of Python. That solved the issue of admin page crashing.

Or

You can install a new version of python (3.7.6 or above) and run your django application there.