question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migrations for auth fails on Django 3.1: KeyError: 'deferrable'

See original GitHub issue

I started a fresh project with Django 3.1. and the latest django-mssql-backend. Running python manage.py migrate auth fails on the “0008” migration:

  Applying auth.0008_alter_user_username_max_length...Traceback (most recent call last):                           File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main                                                                                 execute_from_command_line(sys.argv)
...
  File "/.../lib/python3.6/site-packages/django/db/backends/base/schema.py", line 572, in alter_field
    old_db_params, new_db_params, strict)
  File "/.../lib/python3.6/site-packages/sql_server/pyodbc/schema.py", line 479, in _alter_field
    self.execute(self._create_unique_sql(model, columns=[old_field.column]))
  File "/.../lib/python3.6/site-packages/sql_server/pyodbc/schema.py", line 863, in execute
    sql = str(sql)
  File "/.../venv/lib/python3.6/site-packages/django/db/backends/ddl_references.py", line 200, in __str__
    return self.template % self.parts
KeyError: 'deferrable'

While experimenting a little, downgrading to Django 2.2 fixed the issue with the problematic migrations, and after upgrading back to 3.1 I was able to run the remaining migrations (those that are new in Django 3). Digging into the code base the problem seems quite straightforward: the django.db.backends.ddl_references.Statement seems indeed to expect a deferrable keyword argument, and after hacking the source code so that an empty string was given as deferrable, the migrations worked just fine. Unfortunately I’m not familiar with mssql or this library, and can’t simply attempt a pull request for this.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:11
  • Comments:14

github_iconTop GitHub Comments

9reactions
franzejrcommented, Oct 2, 2020

I confirm downgrading to Django 3.0.10 fixes the issue.

2reactions
OskarPerssoncommented, Jan 11, 2021

Closed in #86

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django and Azure SQL key error 'deferrable' when start ...
Show activity on this post. I try to connect Django to Azure SQL and have the error KeyError: deferrable when I start to...
Read more >
Troubles following the Django tutorial, pt2 mssql backend ...
Hi, I am following the Django tutorial, and on the migration part of the tutorial I get a error message saying “KeyError: 'include'”....
Read more >
Django and Azure SQL key error 'deferrable' when start ...
contrib.auth.models import User >>> User.objects.create(username='alice', pk=1) >>> # The sequence hasn't been updated; its next value is 1. >>> ...
Read more >
KeyError: 'deferrable' - Google Groups
File "/home/sivakrishna/.local/lib/python3.8/site-packages/django/db/backends/ ... I am getting above error When I run command 'python manage.py migrate'.
Read more >
Django Documentation - Read the Docs
Apply all migrations: admin, auth, contenttypes, polls, sessions ... for KeyError and redisplays the question form with an error message if ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found