I have django application, where I wanted to export all migration from my project , auth and admin to sql query. I am able to do
python manage.py sqlmigrate myapp 0001
However, I want to export all migration at same time rather than explicitly righting loops. Is there any package or tool that i can use for this.
you can use squashmigrations command
python manage.py squashmigrations <appname> <squashfrom> <squashto>
and press y
Delete all the before migration files
then run the following command
python manage.py sqlmigrate <appname> <squash_generated_migartion_file>
if you wanted to see the sql for auth migrations
python manage.py sqlmigrate auth 0001_initial
First make sure you are on directory with manage.py file i.e. project directory then, you can do
python manage.py makemigrations
and then run
python manage.py migrate or python manage.py sqlmigrate
I am not able to search and migrate that 1 unapplied migration.
Please help me out
run this "./manage.py makemigrations" again and migrate again.
"./manage.py migrate"
First check migrations list
python manage.py showmigrations --list
In either case, there will be an [X] to show which migrations have been applied.
If you have unapplied migrations the run the command
python manage.py makemigrations
python manage.py migrate
Run python manage.py migrate
If it doesn't work... then delete all files from migrations folder except init.py the go to database and find migrations table, delete all entries. Then again run python manage.py migrate
When I click in my table in http://127.0.0.1:8000/admin/, I see this error:
OperationalError at /admin/home/table/
no such table: home_table.
I ran Python manage.py makemigrations home, Python manage.py makemigrations and Python manage.py migrate but they didn't work.
If you're using sqlite then:
Try unapply all the migrations using using command:
python manage.py appname zero
Then apply the migrations command again. If it still doesn't work then delete your sqlite db and run migrations again. It will work.
I am on Windows server, and when I type "django-admin.py startproject", I'm getting the following message. Looks like I'm not using the command properly, but it is correct. My Django version is Django 1.10, and Pythhon 2.7.
c:\test>django-admin.py startproject mysite
Usage: django-admin.py subcommand [options] [args]
Options:
-v VERBOSITY, --verbosity=VERBOSITY
Verbosity level; 0=minimal output, 1=normal output,
2=verbose output, 3=very verbose output
--settings=SETTINGS The Python path to a settings module, e.g.
"myproject.settings.main". If this isn't provided, the
DJANGO_SETTINGS_MODULE environment variable will be
used.
--pythonpath=PYTHONPATH
A directory to add to the Python path, e.g.
"/home/djangoprojects/myproject".
--traceback Raise on exception
--version show program's version number and exit
-h, --help show this help message and exit
Type 'django-admin.py help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
cleanup
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
runfcgi
runserver
shell
sql
sqlall
sqlclear
sqlcustom
sqldropindexes
sqlflush
sqlindexes
sqlinitialdata
sqlsequencereset
startapp
startproject
syncdb
test
testserver
validate
Simply try this :
django-admin startproject projectname
Thanks.
Try with
python djangoadmin.py startproject mysite
or check this answer.
I want to create the tables of one database called "database1.sqlite", so I run the command:
python manage.py syncdb
but when I execute the command I receive the following error:
Unknown command: 'syncdb'
Type 'manage.py help' for usage.
But when I run
manage.py help
I don`t see any command suspicious to substitute
python manage.py syncdb
Version of Python I use: 3.4.2 Version of Django I use:1.9
I would be very grateful if somebody could help me to solve this issue.
Regards and thanks in advance
If you look at the release notes for django 1.9, syncdb command is removed.
Please use migrate instead. Moving forward, the migration commands would be as documented here
Please note that the django-1.9 release is not stable as of today.
Edit: Django 1.9 is stable now
the new django 1.9 has removed "syncdb",
run "python manage.py migrate",
if you are trying to create a super user, run "python manage.py createsuperuser"
$python manage.py syncdb is deprecated and not supported now.
So instead of this follow below instructions..
Whatever model you have created:
First run:
$python manage.py makemigrations
After running this command you model will be reflected in a migration.
Then you have to run:
$python manage.py migrate
Then run server:
$python manage.py runserver
Now, your project will run perfectly.
In Django 1.9 onwards syncdb command is removed. So instead of use that one, you can use migrate command,eg: python manage.py migrate.Then you can run your server by python manage.py runserver command.
Django has removed python manage.py syncdb command now you can simply use python manage.py makemigrations followed bypython manage.py migrate. The database will sync automatically.
You can run the command from the project folder as: "python.exe manage.py migrate", from a commandline or in a batch-file.
You could also downgrade Django to an older version (before 1.9) if you really need syncdb.
For people trying to run Syncdb from Visual Studio 2015:
The option syncdb was removed from Django 1.9 (deprecated from 1.7), but this option is currently not updated in the context menu of VS2015.
Also, in case you didn't get asked to create a superuser you should manually run this command to create one: python.exe manage.py createsuperuser
Run the command python manage.py makemigratons,and than python manage.py migrate to sync.
Alternarte Way:
Uninstall Django Module from environment
Edit Requirements.txt a type Django<1.9
Run Install from Requirments option in the enviroment
Try Syncdb again
This worked for me.
I also tried this command. Lastly I found the release note from django
Features removed in 1.9
The syncdb command is removed.
Djnago Releases note 1.9
I had the same problem, the only thing worked for me was this command.
python3 manage.py migrate --run-syncdb
Running this got me this result.
Ranvijays-Mac:djangodemo rana.singh$ python3 manage.py migrate --run-syncdb
Operations to perform:
Synchronize unmigrated apps: messages, staticfiles
Apply all migrations: admin, auth, contenttypes, msg, sessions
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Running migrations:
Applying msg.0001_initial... OK