Don't pretend that notifications for m2m works

They don't... And there is no easy way to make them work either, given
the way that signals are called for m2ms.
This commit is contained in:
Magnus Hagander
2016-12-17 14:25:55 +01:00
parent af5e5d327b
commit cb8fd07fd7

View File

@ -53,13 +53,10 @@ def _get_attr_value(obj, fieldname):
# see if this is a Many-to-many field. If yes, we want to print
# it out as a pretty list
if isinstance(obj._meta.get_field_by_name(fieldname)[0], models.ManyToManyField):
# NOTE! If the object is brand new, and it has a many-to-many relationship, we can't
# access this data yet. So just return that it's not available yet.
if not obj.pk:
# No primary key indicates the object doesn't exist yet, so we can't
# access the primary key
return "<not available yet>"
return u", ".join(map(lambda x: unicode(x), getattr(obj, fieldname).all()))
# XXX: Changes to ManyToMany fields can't be tracked here :(
# For now, we have no good way to deal with it so, well, don't.
return ''
# Return the value, or an empty tring if it's NULL (migrated records)
return getattr(obj, fieldname) or ''