Python Django Beginner: can't open manage.py - python

Trying to get started with Django on pycharm.
(venv) C:\Users\Vince\PycharmProjects\assignment>python manage.py runserver
But I get this error message whenever i run manage.py:
C:\Users\Vince\AppData\Local\Programs\Python\Python37-32\python.exe: can't open file 'manage.py': [Errno 2] No such file or directory
I do have a django directory opened with a manage.py file in it. Can anyone assist me on what to do?
I have tried other solutions, like:
python -vvvvv manage.py runserver
python manage.py migrate

You need to either specify the exact location of the manage.py file. I.e.:
python3 Users/Vince/Desktop/DjangoProject/manage.py runserver
or cd to the directory it's in and run from there.
cd Users/Vince/Desktop/DjangoProject > python manage.py runserver

Related

Accidently deleted Profiles and Stubs4 from Django and unable to run manage.py

I wanted to clear the database because I messed in putting correct parameters to update_or_create and create functions of django.For that I deleted the database from pgadmin4 in postgres and deleted all__pycache__, stubs.v4 and the Profiles folder in my django project because I wanted to again feed data into the database.
My goal is to upload a .csv file and fill data row by row (create/update) to database.
Now these errors neither let me create superuser not let me do run manage.py
PS C:\Users\Dell\Desktop\github\DjantoSoft> python manage.py runserver
c:\python37\python.exe: can't open file 'manage.py': [Errno 2] No such file or directory
PS C:\Users\Dell\Desktop\github\DjantoSoft> django-admin createsuperuser
No Django settings specified.
Unknown command: 'createsuperuser'
As told by #aasmpro, the error was that in Visual Studio Code I was out of the folder where manage.py was located.
Also, to empty database python manage.py flush should be used instead.

"manage.py startapp" doesn't create db.sqlite3

I'm following an online tutorial in order to learn Django/Python. I'm using PyCharm Community Edition as my IDE. On Windows 10.
When I run python manage.py startapp myapp at the (venv) prompt in terminal window , no error is shown, and \myapp folder is created with the expected content. However, the file db.sqlite3 is not created, and I can't follow through the rest of the tutorial.
What might be going wrong here?
Thank you very much.
when you start a new django app no database must created.
you can run command
python manage.py migrate
to generate database for your project.
default database is sqlite and stored in file named db.sqlite3
Command python manage.py startapp myapp does not create db.sqlite3.
Run:
python manage.py makemigrations
python manage.py migrate
It will automatically create one if not present.

Cannot start django app

I am a newbie at Django and everytime I try to run (myvenv) C:\Users\lenovo> python manage.py startapp blogit gives me the error:
CommandError: 'blog' conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name.
Am I doing something wrong?
You can't run the command from a directory above your project.
you should do this:
cd projectName
python manage.py startapp blog

Deploy hook for django syncdb not working on openshift

I created a django app on openshift successfully. But, I'm not able to run syncdb using the following deploy hook.
#!/bin/bash
source $OPENSHIFT_HOMEDIR/python/virtenv/bin/activate
cd $OPENSHIFT_REPO_DIR/wsgi/$OPENSHIFT_APP_NAME
python manage.py syncdb --noinput
What could be wrong? Please help!
I think its simply because you forget to add the right for file execution with chmod +x filename

with ./mange.py syncdb getting permission denied in django project

root#domU-xx-xx-39-04-x5-36:/opt/sana# ./manage.py syncdb
-bash: ./manage.py: Permission denied
I tried both django.db.backends.mysql and mysql for 'ENGINE'
I am able to connect to root using
mysql -u root -p
My settings.py file is correct
My Django version is 1.1.1 on Ubuntu LTS 10.04 in EC2
Check manage.py has execute permission. If not give it by
# chmod +x manage.py
List permissions:
ls -l
If it has x permission on the first 3 characters "--x":
./manage.py syncdb
Also, you are able to execute it using python just with read permission "r--":
python manage.py syncdb

Categories

Resources