From cb8fd07fd74a244e249915d6e7b18f1bdbc94e2f Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sat, 17 Dec 2016 14:25:55 +0100 Subject: [PATCH] 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. --- pgweb/util/signals.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pgweb/util/signals.py b/pgweb/util/signals.py index 76d1c747..73e0d9bf 100644 --- a/pgweb/util/signals.py +++ b/pgweb/util/signals.py @@ -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 "" - 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 ''