only add once

This commit is contained in:
Matthias 2022-02-28 19:19:10 +01:00
parent a426742567
commit 28012a3cea
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -146,6 +146,9 @@ class InvenTreeConfig(AppConfig):
def add_user_on_startup(self):
"""Add a user on startup"""
# stop if already created
if hasattr(settings, 'USER_ADDED') and settings.USER_ADDED:
return
# get values
add_user = get_setting(
@ -171,5 +174,6 @@ class InvenTreeConfig(AppConfig):
try:
new_user = user.objects.create_user(add_user, add_email, add_password)
logger.info(f'User {str(new_user)} was created!')
settings.USER_ADDED = True
except Exception as _e:
print(_e)