9

I upgraded recently to Django 1.8. In previous versions of Django, the following import was fine:

from django.contrib.contenttypes.management import update_all_contenttypes

But update_all_contenttypes appears to have been silently removed in Django 1.8 (it was there in 1.7.7). I'm not seeing anything in the 1.8 release notes about its removal... Does anyone know what the modern replacement is for that function?

Troy
  • 21,172
  • 20
  • 74
  • 103

4 Answers4

10

It's unclear why that function was removed in 1.8, but it appears that the modern replacement is to just re-invent that wheel:

from django.apps import apps
from django.contrib.contenttypes.management import update_contenttypes

def update_all_contenttypes(**kwargs):
    for app_config in apps.get_app_configs():
        update_contenttypes(app_config, **kwargs)
Troy
  • 21,172
  • 20
  • 74
  • 103
  • 1
    Could you please look at http://stackoverflow.com/questions/32700638/update-all-contenttypes-seemingly-not-working-with-django-1-8 – Daniel Sep 21 '15 at 17:56
  • 1
    The function `update_contenttypes` has also been removed. – Cerin Nov 28 '17 at 22:14
2

It seems django team has removed the update_contenttypes function without a mention in the release notes because isn't a documented, public API. (as the said here: https://code.djangoproject.com/ticket/28092)

Now you can use instead the new function create_contenttypes, as you can see here: https://github.com/django/django/commit/6a2af01452966d10155b720f4f5e7b09c7e3e419

Luis Sobrecueva
  • 680
  • 1
  • 6
  • 13
0
  • Go to the location of 'django.contrib.contenttypes' in your system (check your 'site-packages' folder of python)
  • Open the app.py (You can use vi app.py in a terminal window)
  • Replace 'update_contenttypes' with 'create_contenttypes'
  • Save the file ('ESC', ‘:’ and ‘wq’ - in a vi editor)

Then try to run the server

-1

create a virtual environment and the error will vanished.

find here how to create a virtual_env:

zaheer
  • 143
  • 10