Reputation: 109
I've created a Django App to be hosted on Azure so I'm using Python Tools for Visual Studio to develop the app. I created a model called Client in models.py in my root app. It's actually a modelform as the table columns are all linked to fields in a form I've created. I'm using MySQL and the connector is MySQLClient as I'm using Python 3.4. I ran python manage.py syncdb
and the following was displayed:
Operations to perform:
Synchronize unmigrated apps: staticfiles, messages, VSpace
Apply all migrations: auth, sessions, contenttypes, sites
Synchronizing apps without migrations:
Creating tables...
Creating table VSpace_Client
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying auth.0001_initial...Traceback (most recent call last):
That is where it fails. I was researching this and I came across something about creating a super user. I tried that but it fails as well after I've entered the credentials. Does anyone know why this is happening?
Edit 1:
Traceback:
Traceback (most recent call last):
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\db\backends\utils.py", line 62, in execute
return self.cursor.execute(sql)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\db\backends\mysql\base.py", line 124, in execute
return self.cursor.execute(query, args)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\MySQLdb\cursors.py", line 220, in execute
self.errorhandler(self, exc, value)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\MySQLdb\connections.py", line 36, in defaulterrorhandler
raise errorvalue
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\MySQLdb\cursors.py", line 209, in execute
r = self._query(query)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\MySQLdb\cursors.py", line 371, in _query
rowcount = self._do_query(q)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\MySQLdb\cursors.py", line 335, in _do_query
db.query(q)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\MySQLdb\connections.py", line 280, in query
_mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1050, "Table 'auth_permission' already exists")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\core\management\__init__.py", line 338, in execute_from_command_line
utility.execute()
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\core\management\__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\core\management\base.py", line 393, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\core\management\base.py", line 444, in execute
output = self.handle(*args, **options)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\core\management\commands\syncdb.py", line 25, in handle
call_command("migrate", **options)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\core\management\__init__.py", line 120, in call_command
return command.execute(*args, **defaults)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\core\management\base.py", line 444, in execute
output = self.handle(*args, **options)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\core\management\commands\migrate.py", line 221, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\db\migrations\executor.py", line 110, in migrate
self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\db\migrations\executor.py", line 148, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\db\migrations\migration.py", line 115, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\db\migrations\operations\models.py", line 59, in database_forwards
schema_editor.create_model(model)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\db\backends\base\schema.py", line 286, in create_model
self.execute(sql, params or None)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\db\backends\base\schema.py", line 111, in execute
cursor.execute(sql, params)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\db\backends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\db\utils.py", line 97, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\utils\six.py", line 658, in reraise
raise value.with_traceback(tb)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\db\backends\utils.py", line 62, in execute
return self.cursor.execute(sql)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\django\db\backends\mysql\base.py", line 124, in execute
return self.cursor.execute(query, args)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\MySQLdb\cursors.py", line 220, in execute
self.errorhandler(self, exc, value)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\MySQLdb\connections.py", line 36, in defaulterrorhandler
raise errorvalue
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\MySQLdb\cursors.py", line 209, in execute
r = self._query(query)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\MySQLdb\cursors.py", line 371, in _query
rowcount = self._do_query(q)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\MySQLdb\cursors.py", line 335, in _do_query
db.query(q)
File "C:\Users\Vinu\Google Drive\VVN Group\VSPace\VSpace Website\VSpace\VSpace\env\lib\site-packages\MySQLdb\connections.py", line 280, in query
_mysql.connection.query(self, query)
django.db.utils.OperationalError: (1050, "Table 'auth_permission' already exists")
The Python REPL process has exited
Upvotes: 0
Views: 1961
Reputation: 4151
The auth_permissions
table already exists in your DB, but the migration thinks it does not. Try to fake the migration to get past this point.
./manage.py migrate auth --fake
Upvotes: 1
Reputation: 141
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
As JwM said syncdb
is being deprecated, now use makemigrations
and migrate
Upvotes: 1
Reputation: 354
First off, try running python manage.py migrate
instead of syncdb
. If I remember correctly the syncdb
command is being deprecated in favor of the makemigrations
and migrate
commands. Try that, and things should go better.
Related: what version of Django are you using?
Upvotes: 1