Reputation: 774
I'm developing a web app in Python 2.7 using Django 1.4 with PyCharm 2.5 as my IDE and a Postgres database. I am able to run manage.py commands such as sql
and syncdb
to create the SQL and the tables, but other commands are not recognized. When I attempt to run sqlreset
(or any other command that drops tables or alters data), I get an "Unknown command" error:
runnerw.exe C:\Python27\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 2.5.1\helpers\pycharm\django_manage.py" sqlreset EventMapperApp C:/Users/Karen/PycharmProjects/eventsMap
Unknown command: 'sqlreset'
Type 'manage.py help' for usage.
Process finished with exit code 1
Could anyone help me figure out what's going on?
Upvotes: 1
Views: 5328
Reputation: 174624
Django's management commands don't automatically run commands that may destroy your database (commands such as altering a table, or changing the type of columns).
If you want to completely reset your application - as if you just ran syncdb
, you need to do it manually.
I wrote this gist that will reset your database. It is not portable (only works on *inx-like systems), but it might help you out.
Note: this will delete (drop) everything.
echo 'from django.conf import settings; print settings.INSTALLED_APPS; quit();' | \
python manage.py shell --plain 2>&1 | \
tail -n1 | sed -r "s|^.*\((.*)\).*$|\1|; s|[',]| |g; s|django\.contrib\.||g" | \
xargs python manage.py sqlclear | \
python manage.py dbshell && python manage.py syncdb
Upvotes: 0
Reputation: 32389
Are you sure you are running Django 1.4? sqlreset
has been deprecated since 1.3, I think, and is slated to be removed in 1.5. It is present in Django 1.4, but has been removed in the development version.
Upvotes: 3
Reputation: 142156
There isn't a sqlreset
.
Info here: https://docs.djangoproject.com/en/dev/ref/django-admin/
or manage.py help
as your post shows...
Upvotes: 0