Как получить данные IntergrityError Django

У меня есть данные IntegrityError следующего вида :

ERROR: Duplicate key value breaks unique constraint "CampaignNamingTool_year_month_advertiser_na_aedc5c8c_uniq"
DETAIL: The key “(year, month, advertiser, name, kpi, type_of_format, device)=(2022, 03, FR - Python, Paris, CPV, Multi-device, IAB)” already exists.

Я хотел бы получить ключ:

(year, month, advertiser, name, kpi, type_of_format, device)=(2022, 03, FR - Python, Paris, CPV, Multi-device, IAB)” already exists.

Как я могу это сделать? Любая помощь будет принята с благодарностью

try:                 
    CampaignNamingTool.objects.bulk_create(list_of_campaign_naming_tool)
except IntegrityError as e:
    messages.error(request, e)
    return redirect('bulk_create_campaign_naming_tool')
               
else:
   msg = "Campaigns successfully uploaded"
   messages.success(request, msg)
   return redirect('bulk_create_campaign_naming_tool')
Вернуться на верх