Only create the object during the signal handling
This commit is contained in:
@@ -20,6 +20,7 @@ from .models import Installation
|
|||||||
def trigger_first_time(sender, **kwargs):
|
def trigger_first_time(sender, **kwargs):
|
||||||
if kwargs['app'] == 'installation':
|
if kwargs['app'] == 'installation':
|
||||||
details, created = Installation.objects.get_or_create()
|
details, created = Installation.objects.get_or_create()
|
||||||
|
if created:
|
||||||
details.is_first_run = True
|
details.is_first_run = True
|
||||||
details.save()
|
details.save()
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ def trigger_first_time(sender, **kwargs):
|
|||||||
def check_first_run():
|
def check_first_run():
|
||||||
try:
|
try:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
details, created = Installation.objects.get_or_create()
|
details = Installation.objects.get()
|
||||||
except DatabaseError:
|
except DatabaseError:
|
||||||
# Avoid database errors when the app tables haven't been created yet
|
# Avoid database errors when the app tables haven't been created yet
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user