Check instance.pk, not instance.id, for members get_list
authorMagnus Hagander <magnus@hagander.net>
Mon, 22 Jul 2024 17:49:09 +0000 (19:49 +0200)
committerMagnus Hagander <magnus@hagander.net>
Mon, 22 Jul 2024 17:49:09 +0000 (19:49 +0200)
Commit f2baae524 added a guard on instance.id to all get_list calls. For
Members that was technically not needed since there is currently no
interface to manually add a member, but it was added for consistency and
future-proofing. But since the Member object doesn't have its own
primary key, it would instead cause a crash. So - change it to look at
the `pk` field which does exist.

Reported by Stacey Haysler, diagnosed by Christophe Pettus

postgresqleu/membership/backendforms.py

index 41cf6a830fcc1b5abc0c2b3795c9fd20daf9cfbf..6a67cc6a44888f810e33a67810598d828c04090f 100644 (file)
@@ -36,7 +36,7 @@ class MemberLogManager(object):
     can_add = False
 
     def get_list(self, instance):
-        if instance.id:
+        if instance.pk:
             return [(None, line.timestamp, line.message) for line in MemberLog.objects.filter(member=instance).order_by('-timestamp')]