Source

django-admin-tools / admin_tools / dashboard / templatetags / admin_tools_dashboard_tags.py

Diff from to

admin_tools/dashboard/templatetags/admin_tools_dashboard_tags.py

 import math
 
 from django import template
+from django.db import IntegrityError
 from django.core.urlresolvers import reverse
 
 from admin_tools.utils import get_media_url, get_admin_site_name
         ).data
     except DashboardPreferences.DoesNotExist:
         preferences = '{}'
-        DashboardPreferences(
-            user=context['request'].user,
-            dashboard_id=dashboard.get_id(),
-            data=preferences
-        ).save()
+        try:
+            DashboardPreferences(
+                user=context['request'].user,
+                dashboard_id=dashboard.get_id(),
+                data=preferences
+            ).save()
+        except IntegrityError:
+            # dashboard already was saved for that (user, dashboard)
+            pass
 
     context.update({
         'template': dashboard.template,