Only create the object during the signal handling

This commit is contained in:
Roberto Rosario
2014-07-18 13:31:41 -04:00
parent 9e50182978
commit fdf33c2296

View File

@@ -20,14 +20,15 @@ from .models import Installation
def trigger_first_time(sender, **kwargs):
if kwargs['app'] == 'installation':
details, created = Installation.objects.get_or_create()
details.is_first_run = True
details.save()
if created:
details.is_first_run = True
details.save()
def check_first_run():
try:
with transaction.atomic():
details, created = Installation.objects.get_or_create()
details = Installation.objects.get()
except DatabaseError:
# Avoid database errors when the app tables haven't been created yet
pass