The command "python manage.py startapp (nameofapp)" doesn't work - python

I've created a basic Django website, and I can't create a new app by using commands such as "python manage.py startapp appname" or "admin-py startapp appname".
I'm learning it through a YouTube tutorial, and the author creates the app that way. Once he has typed this command, the appname appears in PyCharm, but in my case, it doesn't.
Neither python manage.py startapp appname nor admin-py startapp appname seem to work.

I know my answer to your question is too late,
however, in case somebody searched about the same problem and found your question
here is the answe,
just put the appname between "" like in the following line :
python manage.py startapp "appname"
also sometimes you have to type python3 or based on the version of python yoy are having, instead of only python :
python3 manage.py startapp "appname"

Related

Manage.py unknown command

I am a student and my profesor needs me to install Django on PyCharm.
I made a big folder called PyCharmProjects and it includes like everything I have done in Python.
The problem is that I made a new folder inside this PyCharmProjects called Elementar, and I need to have the Django folders in there but it's not downloading.
I type in the PyCharm terminal django-admin manage.py startproject taskmanager1 (this is how my profesor needs me to name it)
After I run the code it says:
No Django settings specified.
Unknown command: 'manage.py'
Type 'django-admin help' for usage.
I also tried to install it through the MacOS terminal but I don't even have acces the folder named Elementar (cd: no such file or directory: Elementar) although it is created and it is seen in the PyCharm.
Manage.py its python file after you start your project, you cant call this file until this command:
django-admin startproject mysite
Then run:
python manage.py runserver
And if you want apps in your project run:
python manage.py startapp my_app
First of all, you can't create a project using manage.py because the manage.py file doesn't exist yet. It will be created automatically in the folder taskmanager1 if you run the command below.
You can create a project with the command
django-admin startproject taskmanager1
After that you can change the directory to the taskmanager1 folder with the cd taskmanager/ command.
When you changed the directory you can use the python manage.py commando for example if you want to run your migrations or creating an app.
python manage.py migrate

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.

Django server not responding

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

Python Django Unknown Command 'SQL'

I'm following this tutorial http://www.sitepoint.com/building-simple-rest-api-mobile-applications/
I'm trying to run SQL by
$ python manage.py sql fishes
However it says
Unknown Command: 'sql'
If I type
$ python manage.py help
I get this, and SQL doesn't appear in the list.
Available subcommands:
[auth]
changepassword
createsuperuser
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
[sessions]
clearsessions
[staticfiles]
collectstatic
findstatic
runserver
Unfortunately that doesn't exist any more, however the command manage.py dbshell does.
Generally speaking however, you should try to use models, with load_data etc to preserve the data integrity (as validations etc may happen in models rather then relying on underlying data bits). Or write management commands for any clean up tasks.
Yes it is possible, using the inspectdb command:
python manage.py inspectdb
or
python manage.py inspectdb > models.py
to get them in into the file
This will look at the database configured in your settings.py and outputs model classes to standard output.
As Ignacio pointed out, there is a guide for your situation in the documentation.
Source : link

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.

Categories

Resources