mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Create setting if it does not exist
This commit is contained in:
parent
549f50ac3f
commit
5908890726
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user