Create setting if it does not exist

This commit is contained in:
Oliver Walters 2020-10-25 22:07:11 +11:00
parent 549f50ac3f
commit 5908890726

View File

@ -204,9 +204,14 @@ class InvenTreeSetting(models.Model):
try:
setting = InvenTreeSetting.objects.filter(key__iexact=key).first()
return setting
except (InvenTreeSetting.DoesNotExist):
return None
# Create the setting if it does not exist
setting = InvenTreeSetting.create(
key=key,
value=InvenTreeSetting.get_default_value(key)
)
return setting
@classmethod
def get_setting_pk(cls, key):