gadventures / django-fsm-admin

Mixin and template tags to integrate django-fsm transitions into the django admin.
Other
203 stars 95 forks source link

Django 1.10: AttributeError: 'Foo' object has no attribute '_deferred' #61

Closed decentral1se closed 7 years ago

decentral1se commented 8 years ago

The Model._deferred attribute is removed as dynamic model classes when using QuerySet.defer() and only() is removed.

https://docs.djangoproject.com/en/1.10/releases/1.10/

The fix is:

diff --git a/fsm_admin/templatetags/fsm_admin.py b/fsm_admin/templatetags/fsm_admin.py
index 3b7e1fb..086c989 100644
--- a/fsm_admin/templatetags/fsm_admin.py
+++ b/fsm_admin/templatetags/fsm_admin.py
@@ -3,6 +3,7 @@ import logging
 from django import template
 from django.contrib.admin.templatetags.admin_modify import submit_row
 from django.conf import settings
+from django.db import models

 register = template.Library()

@@ -47,7 +48,7 @@ def fsm_submit_row(context):
     original = context.get('original', None)
     model_name = ''
     if original is not None:
-        if original._deferred:
+        if original is models.DEFERRED:
             model_name = type(original).__base__._meta.verbose_name
         else:
             model_name = original.__class__._meta.verbose_name
blueyed commented 8 years ago

@lwm You could use a try/except here to be backwards compatible.

decentral1se commented 7 years ago

:rocket: