Refactor out the secret.txt file handling to a utils module
parent
276a926fcb
commit
69655008e0
@ -0,0 +1,11 @@
|
|||||||
|
from django.core.management import utils
|
||||||
|
|
||||||
|
def get_secret_from_file(path):
|
||||||
|
try:
|
||||||
|
with open(path, "r") as f:
|
||||||
|
return f.read().strip()
|
||||||
|
except EnvironmentError:
|
||||||
|
with open(path, "w") as f:
|
||||||
|
secret_key = utils.get_random_secret_key()
|
||||||
|
f.write(secret_key)
|
||||||
|
return secret_key
|
Loading…
Reference in New Issue