4

I'm pretty new to coding in general and could really use someones help with this! I installed django via CMD on my WIN 10 computer and when I run the server it works.

D:\Python\Python37-32\website>manage.py runserver 8080
Performing system checks...

System check identified no issues (0 silenced).
August 04, 2018 - 15:32:59
Django version 2.1, using settings 'website.settings'
Starting development server at http://127.0.0.1:8080/
Quit the server with CTRL-BREAK.

However... I than downloaded Pycharm Community edition on my computer and instead of the server starting, it just opens up the pycharm ide and the server doesnt run. The interpreter looks fine as well.

D:\Python\Python37-32\website>manage.py runserver 8080
D:\Python\Python37-32\website>
noobcoderiam
  • 488
  • 4
  • 19
  • So what changed when you installed Pycharm? Did it mess with (modify/replace) any config/settings files? Did an execution path get changed? Saying that you're new to coding does not relieve you from the requirement that you *own* your environment, and that means being more involved with an install than download-click-go. I suggest you go back to square one in a different directory and then compare the before/after of installing Pycharm. *Somethinig* changed. – Peter Rowell Aug 04 '18 at 21:17
  • So i should uninstall pycharm? or Uninstall python? – noobcoderiam Aug 04 '18 at 21:18

2 Answers2

6

You should change default program for .py files from pycharm to "python"

Nikita Tonkoskur
  • 1,440
  • 1
  • 16
  • 28
  • Thank you! I uninstalled/reinstalled pycharm but didn't select .py extension on the load up. Server runs now! I guess when i ran 'manage.py runserver", it was opening up that file in pycharm instead of running the command? – noobcoderiam Aug 04 '18 at 22:07
  • Good call. Being an Old Linux Fart® I forget about the extension being grabbed by random programs on install. – Peter Rowell Aug 05 '18 at 04:33
  • Thanks for your advice as well Peter! – noobcoderiam Aug 05 '18 at 13:55
0

Simple solution:

python manage.py runserver

However, If you want to run this as manage.py runserver, you should change the default program for .py files from PyCharm to Python:

Right click on any .py file > Properties > General tab > Opens with > Change

(No need to uninstall / reinstall PyCharm)


Then, when you try calling manage.py runserver, you can face another problem: command line arguments (runserver in our case) will not be passed to the program.

The solution to the problem will be some registry configuration:

[HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command]
@="\"C:\\Python38\\python.exe\" \"%1\" %*"

The registry setting above adds the %* to pass all arguments to python.exe

GooDeeJAY
  • 1,681
  • 2
  • 20
  • 27