Django server not responding - python

When I run django-admin startproject newsite in my root directory it works. But afterwards when i run python manage.py runserver in my cmd it doesn't give any results and opens the the new command line interface as it is:
C:\Users\Shiv Chandra Sraswat\Desktop\newsite>python manage.py runserver 0:8000
and there is no result. The answer that comes is
C:\Users\Shiv Chandra Sraswat\Desktop\newsite>
Can anyone tell what is the error ?
thank you

Just run the server with python manage.py runserver
See here for more details: https://docs.djangoproject.com/en/3.0/ref/django-admin/#django-admin-runserver

Just a test. Try to run your project from another folder, one that doesn't have white spaces in it.
For example:
C:\Users\ShivChandraSraswat\Desktop\newsite>
or
C:\Users\anotherUser\Desktop\newsite>
I hope it helps.

There are two possibilities
It may be possible that you don't have manage.py file in C:\Users\ShivChandraSraswat\Desktop\newsite directory
manage.py file is there but it is empty

Related

When I gave command on CMD manage.py runserver it instead took me into VS Code and when i ran it in VS code error was on (from django.core.management)

When I ran the command on CMD manage.py runserver it intern redirected to VS Code. When I tried to run on VS Code it showed the system cannot find the specified path. It was underlining this statement:
try:
from django.core.management
^^^^^^^^^^^^^^^^^^^^^^
first you need to add the python path to your variable environnement
Second
navigate to your django project and use terminal with this command :
python manage.py runserver
use Docs

Django loops infinitly after startapp method call

I'm doing the CS50Web course, and there is a Django project in which I want to create a new app called "wikipedia". The problem is that after I run this command in Windows PowerShell:
python manage.py runserver
this loop happens:
loop print
I don't know what I did wrong for that to happen. After running
python manage.py startapp wikipedia
, I:
went to my Django project and added 'wikipedia' in the installed apps in settings.py
went to urls.py and added a path like this:
path("wiki/", include("wikipedia.urls))
And then I tried running the server. What did I do wrong?
You must have something improperly configured.
Run this:
$ pip uninstall django
$ pip install django
$ django-admin startproject <projectname>
$ cd <projectname>
$ django-admin startapp wikipedia
$ python manage.py makemigrations
$ python manage.py migrate
do what you described in your question
Also, it is always a better idea to run these things in the CMD, rather than in the PowerShell
Are you sure you have url mappings in your wikipedia app urls.py? Not having any patterns there could be the cause of an error.

cannot open manage.py after installing django

I have a problem in setting up django.
My situation: I have Anaconda Python 2.7 in my Windows 8 computer. On the Anaconda command prompt window, I type: pip install django. This is successful.
Then I create a folder named "newproject". On the command prompt I went to the folder "newproject". Then django-admin.py startproject newproject. This is successful.
Then I run python manage.py runserver. It tells me
"...can't open file 'manage.py': [Errno 2] No such file or directory"
I checked out udemy django installation guide and other guides on the net. I have even set up a virtual environment. But the main problem is always: can't open file 'manage.py'
You're not in the proper directory...In the case you described, you should have:
mkdir newproject (not sure why you're doing this...but we'll continue with it)
cd newproject
django-admin.py startproject newproject
cd newproject ← A key missing part from what you did. You need to change into the directory where manage.py resides. Verify it by using ls at the command prompt after switching into the directory.
python manage.py runserver
Use ls often, if you need, to double check where you are in the directory tree.
You are not in the correct directory. You need to do cd newproject and the execute your runserver command.
For me it was because the manage.py didn't get created and the problem was that:
In windows instead of typing "django-admin.py" just type "django-admin" and it will create the manage.py file
you need to change your directory to the directory of the project.
open your environment by typing activate environment_name
change the directory to the folder in which you want to create the
project by cd Folder_Name
then create your project by django-admin startproject
Project_Name
then change the directory to your project folder
if you also want to create an app then typepython manage.py
startapp App_name
to confirm if it works type python manage.py runserver, then
you should get a link in the terminal. copy and paste that link in
the browser and you should see a successful page.
The reason of this problem is because you're in the first project directory "parent directory", and you have to go to your project "newproject" that has the manage.py file.
The way to this is simple:
cd "name of your project", E.g. cd newproject
python manage.py runserver
You need to include a . after you create the project.
Eg: django-admin.py startproject newproject .
This will allow you to run python manage.py runserver from where you are.
That can happen because manage.py doesn't have permissions.
Check the existence of manage.py throughout newproject, If exist you can fix it with:
$cd newproject
$chmod +x manage.py
Finally, try to execute python manage.py runserver
I was having the same problem, when Windows 10 changed credentials, Docker lost the access to drives. The fix for this issue, I reset the credentials in docker-desktop > shared Drives > reset credentials at bottom.
can't open file 'manage.py': [Errno 2] No such file or directory"
here is the solution
step 1: command -> django-admin startproject project_name
step 2: command -> cd project_name
step 3: command -> python manage.py startapp app_name
try it may fix your problem
You should navigate to the inner directory where your manage.py resides. For example:
If you have created projectname as
Django-admin startproject loginapp
Step 1: Go to loginapp
Step 2: Click on it
Step 3: You will find another loginapp and manage.py folder inside that
Step 4: Use this rootpath commandprompt
Step 5: Enter py manage.py runserver
Now it will work
I ran into the same error seller. But this is what I discovered
1: open your terminal in your project environment
2: install Django using: pip install django (if you are on windows)
3: then create your Django project using : django-admin startproject newproject . (django-admin start-project followed by project name give a space and add period (.) )
So it goes like this
django-admin startproject new project .
The period/fullstop (.) At the end tells djando the area in which the file should be created which is inside the project file its self you are working on. After this is done you are free to go. You can now run your server and enjoy
Run server using: python manage.py runserver
Make sure to put a period at the end of your command e.g
Django-admin startproject new project .
The period at the end (.) will solve the problem
There could be invalid interpreter selected .Try selecting the proper interpreter

openshift-django : syncdb, deploy script not running

Is there any way by which I can run syncdb from my terminal? I don't know why my action_hooks/deploy script is not running. When I open my openshift database it show no table created.
source ${OPENSHIFT_HOMEDIR}python-2.6/virtenv/bin/activate
export PYTHON_EGG_CACHE=${OPENSHIFT_HOME_DIR}python-2.6/virtenv/lib/python-2.6/site-packages
echo "Executing 'python ${OPENSHIFT_REPO_DIRwsgi/my/manage.py syncdb --noinput'"
python "$OPENSHIFT_REPO_DIR"my/manage.py syncdb --noinput
echo "Executing 'python ${OPENSHIFT_REPO_DIR}wsgi/my/manage.py collectstatic --noinput -v0'"
python "$OPENSHIFT_REPO_DIR"my/manage.py collectstatic --noinput -v0
git repo at https://github.com/sarvesh-onlyme/ninja/tree/master/openshift/django
How about:
source $OPENSHIFT_HOMEDIR/python-2.6/virtenv/bin/activate
cd $OPENSHIFT_REPO_DIR/wsgi/$OPENSHIFT_APP_NAME
python manage.py syncdb --noinput
Please make sure to do something similar if your application type is python 2.7 based.
let me know if it does not work.
check logs (rhc tail app_name). Try to login to OpenShift app through ssh (rhc ssh app_name) and try to run deploy script manually (cd app-root/runtime/repo/.openshift/action_hooks; ./deploy). Do you see any errors?
Post your logs/errors here. I will update my answer afterwards.
//lol, sorry, I did not notice it's two year old question.

Django manage.py question

Why is it that I have to run python manage.py somecommand and others simply run manage.py somecommand? I'm on OSX 10.6. Is this because there is a pre-set way to enable .py files to automatically run as Python scripts, and I've somehow disabled the functionality, or is that something that you explicitly enable?
If you are using a recent version of Django, the manage.py file should be an "executable" file by default.
Please note, you cannot just type manage.py somecommand into the terminal as manage.py is not on the PATH, you will have to type ./ before it to run it from the current directory, i.e. ./manage.py somecommand.
If that does not work please be sure that the manage.py file has:
#!/usr/bin/env python
as its first line. And make sure it is executable: chmod +x manage.py
There are two things you should look at:
First, is the manage.py script set to be executable? If not, try
chmod u+x manage.py
Secondly, does manage.py have a valid hashbang line? If not, you could try adding one that points to the correct python interpreter for your system.
On the mac the manage.py command has to be executable to just run it without the python command. You can do this with:
chmod 755 manage.py
If you are in the same directory as manage.py, to run it you type:
./manage.py somecommand
Otherwise you want to specify the path:
/path/to/my/project/manage.py somecommand

Categories

Resources