echo
echo

Reputation: 480

Django local dev server hangs with chrome after form submission. Works in firefox

Ok this is a strange one.

Here is what I do to reproduce the problem (windows 10/python 3.7.1/django 2.5.5):

  1. Create a new virtual env with virtualenv-wrapper and 'mkvirtualenv' command
  2. Install Django in the virtual env using 'pip install django'
  3. Create a new Django project
  4. Migrate for first time to default sqlite database
  5. createsuperuser
  6. Run dev server
  7. Access 127.0.0.1:8000/admin via chrome
  8. Log in with superuser credentials

I see a http post in the dev server console window. It looks like this:

(default-users) C:\Users\kmfae\Documents\test\django-default-users>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
September 05, 2019 - 19:13:22
Django version 2.2.5, using settings 'defusers_project.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[05/Sep/2019 19:13:40] "GET /admin HTTP/1.1" 301 0
[05/Sep/2019 19:13:40] "GET /admin/ HTTP/1.1" 302 0
[05/Sep/2019 19:13:40] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 1819
[05/Sep/2019 19:13:40] "GET /static/admin/css/login.css HTTP/1.1" 200 1233
[05/Sep/2019 19:13:40] "GET /static/admin/css/base.css HTTP/1.1" 200 16378
[05/Sep/2019 19:13:40] "GET /static/admin/css/responsive.css HTTP/1.1" 200 17944
[05/Sep/2019 19:13:40] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[05/Sep/2019 19:13:40] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 85876
[05/Sep/2019 19:13:40] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 85692
[05/Sep/2019 19:13:47] "POST /admin/login/?next=/admin/ HTTP/1.1" 302 0

But in the chrome browser I don't get redirected to the admin site. It sits there forever with the spinning icon as if it's loading a page. At least most of the time it does that. Rarely it actually does work as it should.

The same exact process works every time in firefox. Here's what the dev server looks like when I use firefox. Notice it gets past the initial http post where chrome gets hung:

(default-users) C:\Users\kmfae\Documents\test\django-default-users>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
September 05, 2019 - 19:06:37
Django version 2.2.5, using settings 'defusers_project.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[05/Sep/2019 19:06:45] "GET /admin/ HTTP/1.1" 302 0
[05/Sep/2019 19:06:45] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 1819
[05/Sep/2019 19:06:52] "POST /admin/login/?next=/admin/ HTTP/1.1" 302 0
[05/Sep/2019 19:06:52] "GET /admin/ HTTP/1.1" 200 3042

Anyone have ideas what's going on???

Upvotes: 0

Views: 608

Answers (1)

JavDomGom
JavDomGom

Reputation: 1175

You have two solutions:

  • Upgrade Python to version 3.8, remove and rebuild the virtual environment.

or

  • Downgrade Django from 3.0 to 2.2 version.
    pip install "django>=2.2,<3"
    

Both solutions fix this problem. Execute python manage.py runserver and logged into admin panel again.

Seems to be a problem with Python 3.7 and Django 3.0.

Upvotes: 0

Related Questions