diff --git a/api/models.py b/api/models.py index 20c82f8..65e63b9 100644 --- a/api/models.py +++ b/api/models.py @@ -1,7 +1,4 @@ -import re -import unicodedata -import logging -import types +import uuid from django.db import models @@ -12,6 +9,12 @@ class AuthAPIKey(models.Model): active = models.BooleanField(default=True) key = models.CharField("API Key", max_length=200) + def save(self, *args, **kwargs): + if not key or key = '': + self.key = uuid.uuid4() + + models.Model.save(self, *args, **kwargs) + class AuthAPILog(models.Model): access_datetime = models.DateTimeField()