0

I have Django code, and it is running fine, but when I run manage.py, it raises an error which I do not understand:

Operations to perform:
  Apply all migrations: admin, api, auth, contenttypes, sessions, social_django
Running migrations:
  Applying api.0004_auto_20190726_1113...Traceback (most recent call last):
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\backends\sqlite3\base.py", line 298, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: near ")": syntax error

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

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\management\__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\management\base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\management\base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\core\management\commands\migrate.py", line 203, in handle
    fake_initial=fake_initial,
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\migrations\executor.py", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\migrations\migration.py", line 124, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\migrations\operations\fields.py", line 150, in database_forwards
    schema_editor.remove_field(from_model, from_model._meta.get_field(self.name))
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\backends\sqlite3\schema.py", line 327, in remove_field
    self._remake_table(model, delete_field=field)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\backends\sqlite3\schema.py", line 274, in _remake_table
    self.quote_name(model._meta.db_table),
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\backends\base\schema.py", line 133, in execute
    cursor.execute(sql, params)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\backends\utils.py", line 100, in execute
    return super().execute(sql, params)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\backends\utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "C:\Users\santhoshe.e\AppData\Local\Continuum\anaconda3\lib\site-packages\django\db\backends\sqlite3\base.py", line 298, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: near ")": syntax error

0004_auto_20190726_111:

from django.db import migrations, models

class Migration(migrations.Migration):

    dependencies = [
        ('api', '0003_support_sql_server'),
    ]

    operations = [
        migrations.AlterUniqueTogether(
            name='seq2seqannotation',
            unique_together=set(),
        ),
        migrations.RemoveField(
            model_name='seq2seqannotation',
            name='document',
        ),
        migrations.RemoveField(
            model_name='seq2seqannotation',
            name='user',
        ),
        migrations.RemoveField(
            model_name='seq2seqproject',
            name='project_ptr',
        ),
        migrations.AlterUniqueTogether(
            name='sequenceannotation',
            unique_together=set(),
        ),
        migrations.RemoveField(
            model_name='sequenceannotation',
            name='document',
        ),
        migrations.RemoveField(
            model_name='sequenceannotation',
            name='label',
        ),
        migrations.RemoveField(
            model_name='sequenceannotation',
            name='user',
        ),
        migrations.RemoveField(
            model_name='sequencelabelingproject',
            name='project_ptr',
        ),
        migrations.AlterField(
            model_name='project',
            name='project_type',
            field=models.CharField(choices=[('DocumentClassification', 'document classification')], max_length=30),
        ),
        migrations.DeleteModel(
            name='Seq2seqAnnotation',
        ),
        migrations.DeleteModel(
            name='Seq2seqProject',
        ),
        migrations.DeleteModel(
            name='SequenceAnnotation',
        ),
        migrations.DeleteModel(
            name='SequenceLabelingProject',
        ),
    ]

I do not understand this error and am not able to understand where I need to change my code. Can anyone please suggest me where I need to change the code?

James Z
  • 12,209
  • 10
  • 24
  • 44
Bindu Machani
  • 71
  • 1
  • 1
  • 4
  • Add `0004_auto_20190726_1113` migration file code in your question. – shafik Jul 27 '19 at 05:02
  • To see a list of SQL generated by the Django Migration module, you can use `python manage.py sqlmigrate api 0004`. Please update the data output here. Perhaps this question is related : https://stackoverflow.com/questions/37955984/trying-to-migrate-in-django-1-9-strange-sql-error-django-db-utils-operationa/37979963 – youngminz Jul 27 '19 at 10:38

0 Answers0