dimanche 10 mai 2015

django: no such table: collegesInfo_branch_course migration error

here is my django code: I'm trying to add many to many field to branch model but the migrate command is giving error.

Details are as follows.

class Branch(models.Model):
    branchName = models.CharField(max_length=300)
    searchRank = models.IntegerField()
    course = models.ManyToManyField('Course')
    def __unicode__(self):
        return self.branchName + ', searchRank.'+str(self.searchRank) 


class Course(models.Model):
    courseName = models.CharField(max_length=500)
    degree = models.CharField(max_length=300, null=True, blank=True)
    approval = models.CharField(max_length=300, null=True, blank=True)
    duration = models.FloatField(null=True, blank=True)

following is the commend used to make migrations.

python manage.py makemigrations collegesInfo

Migrations for 'collegesInfo':
  0005_branch_course.py:
    - Add field course to branch

command use to apply migrations

 python manage.py migrate            

here is the error given by django

Operations to perform:
  Synchronize unmigrated apps: web_project
  Apply all migrations: sessions, admin, applicant, auth, default, contenttypes, collegesInfo
Synchronizing apps without migrations:
  Creating tables...
  Installing custom SQL...
  Installing indexes...
Running migrations:
  Applying collegesInfo.0002_auto_20150510_0219...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 160, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 63, in migrate
    self.apply_migration(migration, fake=fake)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 97, in apply_migration
    migration.apply(project_state, schema_editor)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 107, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 84, in database_forwards
    schema_editor.remove_field(from_model, from_model._meta.get_field_by_name(self.name)[0])
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/db/backends/sqlite3/schema.py", line 178, in remove_field
    self.delete_model(field.rel.through)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/db/backends/sqlite3/schema.py", line 151, in delete_model
    super(DatabaseSchemaEditor, self).delete_model(model)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/db/backends/schema.py", line 289, in delete_model
    "table": self.quote_name(model._meta.db_table),
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/db/backends/schema.py", line 99, in execute
    cursor.execute(sql, params)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 81, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/home/sanyam/ABEC-devEnv/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 485, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: collegesInfo_branch_course

Please help to solve this error

Aucun commentaire:

Enregistrer un commentaire