Skip to content

Instantly share code, notes, and snippets.

@Kniyl
Created May 12, 2015 17:38
Show Gist options
  • Save Kniyl/a515bc600fb4b949da85 to your computer and use it in GitHub Desktop.
Save Kniyl/a515bc600fb4b949da85 to your computer and use it in GitHub Desktop.
Quick fix for django-modeltranslation with Django 1.8
diff --git a/modeltranslation/translator.py b/modeltranslation/translator.py
index 18bc743..c6edfb6 100644
--- a/modeltranslation/translator.py
+++ b/modeltranslation/translator.py
@@ -150,7 +150,12 @@ def add_translation_fields(model, opts):
# Rebuild information about parents fields. If there are opts.local_fields, field cache would be
# invalidated (by model._meta.add_field() function). Otherwise, we need to do it manually.
if len(opts.local_fields) == 0:
- model._meta._fill_fields_cache()
+ try:
+ model._meta._fill_fields_cache()
+ except AttributeError:
+ # Django 1.8 removed _fill_fields_cache
+ model._meta._expire_cache()
+ model._meta.get_fields()
def has_custom_queryset(manager):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment