1

I'm upgrading django from 1.8 to 1.11 and this imports are failing

from django.core.management.sql import sql_delete
*** ImportError: cannot import name sql_delete

from django.core.management.sql import sql_all
*** ImportError: cannot import name sql_all

I was looking for the remove mention in the releases notes but I couldn't find anything. Does anyone know when were removed and any alternative to replace it?

Luis Sobrecueva
  • 680
  • 1
  • 6
  • 13

1 Answers1

1

In Django 1.7+, the recommended approach would be to use migrate and sqlmigrate instead of syncdb and sqlall.

I don't think that the sql_all and sql_delete functions were ever a public API, therefore their removal didn't have to be mentioned in the release notes. They were removed in this commit, which was included in Django 1.9.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • Thanks for the commit reference, without these functions do you know how I could get a list of the DROP TABLE SQL statements for the given app and a list of CREATE TABLE SQL, initial-data inserts, and CREATE INDEX SQL for the given module? – Luis Sobrecueva Apr 27 '18 at 09:28
  • The [`sqlmigrate`](https://docs.djangoproject.com/en/2.0/ref/django-admin/#django-admin-sqlmigrate) command is the closest thing I can think of, but that gives you the list of SQL commands for a specific migration, not for the app. – Alasdair Apr 27 '18 at 09:35