python: can't open file 'manage.py' when I create django app - python

I created a project named testdj, and under the directory /tmp/python-test/testdj/testdj/, I want to create a django app, so I use the below command:
aircraftdeMacBook-Pro:testdj ldl$ python manage.py startapp TestModel
python: can't open file 'manage.py': [Errno 2] No such file or directory
But the the upper error, can't open file 'manage.py' there.
I find the stack overflow, there is some the same error, but they are not when creating app occurs.

i guess you are using django app,
so first
pip install django
django-admin startproject project_name
django-admin startapp app_name
python manage.py runserver

Related

I updated python to 3.7 from 3.5 and now manage.py cannot be found

(venv) C:\Users\...\PycharmProjects\WebP1>python manage.py runserver
C:\Users\...\AppData\Local\Programs\Python\Python37-32\python.exe: can't open file 'manage.py':
[Errno 2] No such file or directory
This is the error I get post updating to Python. Just before i updated the command was working and I could run my website.
Should I revert back to 3.5 or how can I actually get my py file to be found?
I needed to be another directory deep when doing the command after the update took place. For some reason the update moved me out a directory.
cd [folder name]
(venv) C:\Users\...\PycharmProjects\WebP1\[folder name]>python manage.py runserver

How to do run:"python manage.py runserver in vscode.i want to run a new server for my project

How to do run: python manage.py runserver in Visual Studio Code?
I get the below error
"Can not open file manage.py:no such file or directory"
go to that folder where is you 'manage.py' file through cm
Folder name
and then run you command
python3 manage.py runserver
In vscode terminal (Ctrl+\ hotkey) change path (with cd command) to directory where manage.py file of your project saved, and then run python manage.py runserver

how to call different settings from manage.py in django

I'm trying to call environment specific settings in django.
I found that you can do something close in django admin according to: https://docs.djangoproject.com/en/2.0/topics/settings/#the-django-admin-utility
I tried this with the manage.py:
python3 manage.py runserver --settings=mysite.settings.prod_settings
I get the error:
ModuleNotFoundError: No module named 'mysite.settings.prod_settings';
'mysite.settings' is not a package
How can I call environment specific settings?
Thanks
I changed the command to:
python3 manage.py runserver --settings=mysite.prod_settings
because I have a file called prod_settings.py and it worked.

can't open file django-admin.py, no such file error

I'm trying to start a django project in Cygwin with: django-admin.py startproject mysite However, I'm getting the following errors:
C:\Python34\python.exe: can't open file '/cygdrive/c/Python34/Scripts/django-admin.py': [Errno 2] No such file or directory
My PATH in Windows include paths to "django-admin.py":
...;C:\cygwin64;C:\cygwin64\usr\sbin;C:\Python34;C:\Python34\Scripts;C:\Python34\Lib\site-packages\django\bin;...
Instead of using
django-admin runserver
try this
C:\Users\Admin\Desktop\github\django\Scripts\django-admin.py runserver
here the django stands for virtual environment

Exist a diference in use django-admin.py or manage.py

I'm learning something about Django.In some tutorials that i've read is used django-admin.py for execute commands like " syncdb, startapp and startproject", in the others tutorials is used manage.py, So exist any important diference between use django-admin.py or manage.py ?
See: django-admin.py and manage.py in Django documentation
manage.py is a wrapper around django-admin.py automatically created in each Django project which puts your project's package on sys.path and sets the DJANGO_SETTINGS_MODULE environment variable so that it points to your project's settings.py file.
So, I think is more comfortable to use manage.py when you're working on a Django project.
manage.py is a file that excists in a project environment and is created after starting a project. It's purpose is to control project commands. Django-admin.py is a script to start a project ( you can put it anyhwhere, or shortcut it via .bash or .profile )
manage.py is django-admin fitted in your project: it uses settings.py in your project dir

Categories