Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
decentral1se opened this issue Aug 25, 2016 · 2 comments · Fixed by #65
Closed

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

decentral1se opened this issue Aug 25, 2016 · 2 comments · Fixed by #65

Comments

@decentral1se
Copy link
Contributor

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
Copy link

blueyed commented Aug 25, 2016

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

jrief added a commit to jrief/django-fsm-admin that referenced this issue Nov 5, 2016
Nagyman pushed a commit that referenced this issue Nov 21, 2016
* Fix #63: AttributeError: Options object has no attribute get_field_by_name

* Fix #61: AttributeError: object has no attribute _deferred
@decentral1se
Copy link
Contributor Author

🚀

pkolios pushed a commit to lock8/django-fsm-admin that referenced this issue Mar 6, 2018
* Fix gadventures#63: AttributeError: Options object has no attribute get_field_by_name

* Fix gadventures#61: AttributeError: object has no attribute _deferred
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants