Skip to content

Commit

Permalink
Fixed Team(s) field not pre-populating when editing a Contact (#5476)
Browse files Browse the repository at this point in the history
  • Loading branch information
HanlinMiao committed Mar 28, 2024
1 parent 1cc71c3 commit 1bf39ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions changes/5415.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed Team(s) field not pre-populating when editing a Contact.
7 changes: 7 additions & 0 deletions nautobot/extras/forms/contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ class Meta:
"tags",
]

def __init__(self, instance=None, initial=None, **kwargs):
if instance is not None:
if initial is None:
initial = {}
initial.setdefault("teams", instance.teams.all())
super().__init__(instance=instance, initial=initial, **kwargs)

def save(self, *args, **kwargs):
"""
Since `teams` field on Contact Model is the reverse side of an M2M,
Expand Down

0 comments on commit 1bf39ab

Please sign in to comment.