Data overwrite on syncdb in django

139 Views Asked by At

I had a django project "demo_project", I ran syncdb command and created tables and saved data. Then I took a copy of this project "demo_project_copy" and ran syncdb command. Now I can't login with previous data which was stored in database(error: invalid credentials). And when I run syncdb on "demo_project" I get error . did syncdb on "demo_project_copy" overwrite the data of "demo_project" ? What happened?

1

There are 1 best solutions below

2
On

syncdb doesn't overwrite the database data, it just add the database tables that you need for the application you installed in your project. So if you add a new application in the INSTALLED_APPS in the settings.py file and then run syncdb, the command will add the necessary tables, nothing more.

If you are using django 1.7.x you'd better use the migrate command, since django 1.7.x syncdb is deprecated.

Reference for the syncdb command, documentation is very good for django: https://docs.djangoproject.com/en/1.6/ref/django-admin/#syncdb