manage.py runserver opens up pycharm instead of running server - python

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>

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

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
via: mckoss's answer on stackoverflow

Related

entering manage.py runserver in the shell, the Django server opens Texteditor instead of starting the server

When I type manage.py runserver in the shell, there only opens my text editor, instead of starting the server. I do not understand this issue. The documentation of django says, the server should start.
to start the server u should type python manage.py runserver and
before this make sure that you are in the correct dir and also make sure you are working within your created environment.
Solution was to go in windows default settings and change the program to open .py files to python

python manage.py runserver not working on on localhost:8000

I am new to django and trying to run the django server for the first time. I am trying to run the command for starting a django server in a terminal, i.e. python manage.py runserver. But when I go to http://localhost:8000, it is not giving me the default django output containing a rocket like image.
I even tried using http://my_ip:8000 and http://127.0.0.1:8000 but still it doesn't work. I also tried running the command as python manage.py runserver 8000 but it still does not give me anything on localhost:8000.
I have checked and no firewall / antivirus is blocking this port for me. Also, I am able to access other applications on other ports.
I am not getting any errors on my terminal when I run this command. This is a blocker for me and any help would be really appreciated.
Follow the image of my vs code integrated terminal here
Find my image of browser navigated to http://localhost:8000 over here.
I am using the latest python version 3.9 and my django version is 3.2.
Thanks!

Development server is not starting and getting no response

I am a beginner for django web development. Initially i created a project and an app. When i try to run the django server using the python manage.py runserver command it loads for sometime and i get no response.
I am using Pycharm 2019 community edition
You mention you are using PyCharm. Can you use your terminal window within PyCharm (normally at the bottom, possible toggle view with Alt+F12). In that terminal window try typing python manage.py runserver and see if that gives you an error.

Local Django server cannot connect when run through Bash on Windows

I recently realized that I could use Bash for Windows as the terminal for use in Pycharm so that the IDE had a proper terminal in it even through it was in Windows. I want to work on a Django project but I realized something strange. When I run the server through the IDE's run button, everything runs as expected. However, when I try to run the server through the command line via
python3 manage.py runserver,
the terminal output is the same, but my browsers cannot connect. Instead they say that the connection was reset. I have full installations of Django and Python for both Windows and the Bash environment and both seem to be fully functional. I can make migrations and create new apps through the command line just fine, but I was wondering if anybody else knew why the Django Server does not connect when run through Bash on Windows

How to run Python server without command prompt

I'm developing some Python project with Django. When we render the Python/Django application, we need to open the command prompt and type in python manage.py runserver. That's ok on for the development server. But for production, it looks funny. Is there anyway to run the Python/Django project without opening the command prompt?
The deployment section of the documentation details steps to configure servers to run django in production.
runserver is to be used strictly for development and should never be used in production.
You run the runserver command only when you develop. After you deploy, the client does not need to run python manage.py runserver command. Calling the url will execute the required view. So it need not be a concern
If you are using Linux I wrote a pretty, pretty basic script, which I am always using when I don't want to call this command.
Note: You really just should use the "runserver" for developing :)
#!/bin/bash
#Of course change "IP-Address" to your current IP-Address and the "Port" to your port.
#ifconfig to get your IP-Address
python manage.py runserver IP-Address:Port
just name it runserver.sh and execute it like this in your terminal:
./runserver.sh

Categories