Skip to content

Commit e4e2c78

Browse files
MajesticFalconcimnine
authored andcommitted
Update 290_webhooks.py
Move to a more standard method of object handling
1 parent 2e5d846 commit e4e2c78

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

startup_scripts/290_webhooks.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ def get_content_type_id(content_type_str):
2020
obj_types = hook.pop('object_types')
2121
obj_type_ids = [ get_content_type_id(obj) for obj in obj_types ]
2222
if obj_type_ids is not None:
23-
webhook = Webhook(**hook)
24-
if not Webhook.objects.filter(name=webhook.name):
25-
webhook.save()
23+
webhook, created = Webhook.objects.get_or_create(**hook)
24+
if created:
2625
webhook.content_types.set(obj_type_ids)
2726
print("🖥️ Created Webhook {0}".format(webhook.name))

0 commit comments

Comments
 (0)