Vetri Selvi Vairamuthu
Vetri Selvi Vairamuthu

Reputation: 103

exception messages: What does it mean? - django 1.8 python 3.4 - python manage.py makemigrate

This is the error message: Not sure what is the exception message mean. Plus I don't seem to get any error while running the local server. So is it going to throw any error in the future?

(proj1) C:\Users\vetri\Google Drive\proj1\src>python manage.py mak
emigrations
No changes detected

(proj1) C:\Users\vetri\Google Drive\proj1\src>python manage.py mig
rate
Operations to perform:
  Synchronize unmigrated apps: messages, staticfiles
  Apply all migrations: contenttypes, sessions, admin, Index, auth
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying Index.0001_initial...Traceback (most recent call last):
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\utils.py", line 62, in execute
    return self.cursor.execute(sql)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\sqlite3\base.py", line 316, in execute
    return Database.Cursor.execute(self, query)
sqlite3.OperationalError: table "Index_usermanagement" already exists

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\core\m
anagement\commands\migrate.py", line 221, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\mig
rations\executor.py", line 110, in migrate
    self.apply_migration(states[migration], migration, fake=fake, fake_initial=f
ake_initial)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\mig
rations\executor.py", line 147, in apply_migration
    state = migration.apply(state, schema_editor)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\mig
rations\migration.py", line 115, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, projec
t_state)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\mig
rations\operations\models.py", line 59, in database_forwards
    schema_editor.create_model(model)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\base\schema.py", line 286, in create_model
    self.execute(sql, params or None)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\base\schema.py", line 111, in execute
    cursor.execute(sql, params)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\uti
ls.py", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\utils\
six.py", line 658, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\utils.py", line 62, in execute
    return self.cursor.execute(sql)
  File "C:\Users\vetri\Google Drive\proj1\lib\site-packages\django\db\bac
kends\sqlite3\base.py", line 316, in execute
    return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: table "Index_usermanagement" already exists

(proj1) C:\Users\vetri\Google Drive\proj1\src>

Upvotes: 1

Views: 298

Answers (2)

FlipperPA
FlipperPA

Reputation: 14311

It looks like you may be moving to Django 1.8 for a model that already has an existing table. For Django 1.8, you'll want to use --fakeinitial option, which use to be implicit but now must be called explicitly starting in 1.8.

Documentation:

https://docs.djangoproject.com/en/1.8/ref/django-admin/#django-admin-option---fake-initial

Upvotes: 1

Ajay Gupta
Ajay Gupta

Reputation: 1285

You must have run syncdb before doing the migrations or anothee possible reason is that using some other version of your database which already have this table Try to remove your table 'Index_usermanagement' which already exists! After that again run

python manage.py migrate

Upvotes: 1

Related Questions