Commits

Leonardo Santos  committed 1e4b148

Increased to version 0.2.6

Fixing inoa.models.utils.default_repr to prevent AtributeErrors

  • Participants
  • Parent commits 0fce392

Comments (0)

Files changed (2)

File inoa/models/utils.py

     Better default unicode representation for models, which includes the instance verbose name and ID.
     If the inoa app is in INSTALLED_APPS, this replaces all models' default __unicode__() method automatically.
     """
-    if extra_info:
-        return u"#%d: %s" % (obj.id, extra_info)
-    else:
-        return u"%s #%d" % (obj._meta.verbose_name.capitalize(), obj.id)
+    if obj is None:
+        return
+
+    try:
+        if extra_info:
+            return u"#%d: %s" % (obj.id, extra_info)
+        else:
+            return u"%s #%d" % (obj._meta.verbose_name.capitalize(), int(obj.id))
+    except:
+        return repr(obj)
 
 def clone_instance(obj):
     """
 
 setup(
     name='django-inoa',
-    version='0.2.5',
+    version='0.2.6',
     author='Inoa',
     author_email='django@inoa.com.br',
     packages=packages,