0

I'm new to Django and now getting stuck in running up the server. I've installed the following components on Windows 10:

Python 3.7.0
Django 1.11.14
Geckodriver 0.21.0

I can successfully create a project using django-admin.py startproject {project_name} .
but when I run python manage.py runserver, the Git Bash doesn't seem to make any progress and the process gets stuck there forever.

$ python manage.py runserver
|

I'm supposed to get something like the following output though,

Performing system checks...

System check identified no issues (0 silenced).

Django version 1.8.3, using settings 'projectname.settings' Starting >development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK.

I've also activated the virtualenv too. What could be the cause of this problem?

Community
  • 1
  • 1
khunzohn
  • 11
  • 4

4 Answers4

1

Thing is when you run python manage.py runserver by default it will run with auto reload.

Means when you change any file it will re-run or relaod again where it might be needed to kill and start port e.g 8080.

Unfortunately GitBash is more lighter one which is not capable to kill process.Have one workaround to run with not auto reload. like below:

python manage.py runserver --noreload
Osman Goni Nahid
  • 1,193
  • 2
  • 15
  • 24
  • I tried with that command but it now returns SyntaxError instead of the cursor blinking. – khunzohn Jul 24 '18 at 05:54
  • Ah actually had same issue 3 year ago and I tried like this. But instead of gitbash try powershell then. – Osman Goni Nahid Jul 24 '18 at 06:27
  • Tried with both command prompt & powershell but it returns the same SyntaxError too. – khunzohn Jul 24 '18 at 06:39
  • This is the ending part of the error `from django.contrib.admin.filters import ( File "D:\kz\python\python-tdd-book\virtualenv\lib\site-packages\django\contrib\admin\widgets.py", line 152 '%s=%s' % (k, v) for k, v in params.items(), SyntaxError: Generator expression must be parenthesized` – khunzohn Jul 24 '18 at 06:41
  • This [answer](https://stackoverflow.com/a/48822656/5722054) says there's a problem between Django and python 3.7. So I ended up installing python 3.6 and things are working as expected after that. – khunzohn Jul 24 '18 at 06:49
0

I also think you should try using the windows command prompt instead

0

Quite literally exit bash, reopen bash, and run your server it will no longer hang. I had the same issue anytime I made changes to my server database configuration(make/run migrations). I can't root cause it, it may be a linux running inside windows thing, but I'm not sure.

Charley Erd
  • 103
  • 1
  • 1
  • 7
0

It works by

winpty python manage.py runserver

You can add an alias to your .bashrc by

echo "alias python='winpty python.exe'" >> ~/.bashrc

More info here

azalea
  • 11,402
  • 3
  • 35
  • 46