manage.py command returns help text - python

I have a problem with manage.py - it returns 'help' instead of creating an app. I'm quite new in Django so it could be obvious.
I've created a Django project using PyCharm.
New Project../Django../Projct
So PyCharm created a directory called Projct which looks like:
Projct/
Projct/
__init__.py
settings.py
urls.py
wsgi.py
Templates/
manage.py
Now, I want to start on project so I change a name of the SQLite database and do this command:
...PycharmProjects/Projct/manage.py startapp projct
Cmd returns:
Available subcommands
[auth]
changepassword
createsuperuser
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runfcgi
shell
showmigrations
sql
sqlall
sqlclear
sqlcustom
sqldropindexes
sqlflush
sqlindexes
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
syncdb
test
testserver
validate
[sessions]
clearsessions
[staticfiles]
collectstatic
findstatic
runserver
I've already tried syncdb and it returns the same list.
Do you know where is the problem?

Try to do the following in Pycharm Ctrl+Alt+R, when the new window comes up, type in runserver and hit enter.

Related

"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.

python app not starting in visual studio

I have created django python app, and when I press F5 , it pops up a python shell which says
Available subcommands:
[auth]
changepassword
createsuperuser
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runfcgi
shell
showmigrations
sql
sqlall
sqlclear
sqlcustom
sqldropindexes
sqlflush
sqlindexes
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
syncdb
test
testserver
validate
[sessions]
clearsessions
[staticfiles]
collectstatic
findstatic
runserver
Press any key to continue . . .
But it does not open any browser and app is not running, when I hit any key , it just stops the app.
I am wondering what is the issue. Weird thing is few days ago this app was working fine and I didn't do anything after that.
I resolved the issue. The issue was with the port 8000, my system was not allowing me to access port number: 8000.
So I went to VisualStudio ---->Debug ----> Project properties at bottom ---> Debug --->enter port number : 5000
and then it worked like charm.

django: by mistake deleted migration files from production server

By mistake I deleted all the migration files from all apps on production server.
Now running python manage.py makemigrations and then python manage.py migrate raises:
"field already exists in the database"
error for each field, What should I do ?
django version: 1.7.7
If you already migrated and then deleted.Then fake will help you
python manage.py migrate --fake
you have to fake the migration, the next command may help you:
python manage.py migrate 'name_app' 'name_migration' --fake
Example:
python manage.py migrate books 005_auto_20150505 --fake

From Django1.7 onwards `migration` is into the core. Is it similar to `south`?

I am using south for migrations. Today I surprisingly found an interesting article, django1.7 support migrations.
Interestingly I found that the startapp command even creates a folder migrations.
python manage.py startapp myapp
has tree:
myapp/
admin.py
models.py
views.py
tests.py
migrations/ <-- folder migrations
I also found command ./manage.py makemigrations, is it similar to:
./manage.py schemamigration myapp --initial or ./manage.py schemamigration myapp --auto
So what about datamigration??
Also found command ./manage.py migrate, i hope it is similar to south's ./manage.py migrate command.
So there is no ./manage.py syncdb command in django1.7??
Django 1.7 migrations are successor to South migrations.
And since there are now migrations old syncdb was deprecated. Syncdb should be working still for few versions.
You can read more details what was changed in 1.7 release notes:

Django "Table already exists" on testing

I've tried to solve the following issue:
I'm running python manage.py test to test my application.
After creating a new test_app database, I'm getting
DatabaseError: (1050, "Table 'auth_group' already exists")
I haven't installed South (it's not on the INSTALLED_APPS list), how do I solve this?
Install south is the best way for django
You should use south like this if be the first one:
python manage.py syncdb --settings= SETTINGS_NAME
python manage.py convert_to_south APP_NAME --settings= SETTINGS_NAME
python manage.py schemamigration APP_NAME --initial --settings= SETTINGS_NAME
python manage.py migrate APP_NAME --fake --settings= SETTINGS_NAME
If you made the migrations use the following sentences:
python manage.py schemamigration APP_NAME --auto
python manage.py migrate APP_NAME --settings= SETTINGS_NAME)
you should use python manage.py migrate app_name rather than python manage.py migrate.Because you had used it before

Categories

Resources