Init the API key if it doesnt exist

This commit is contained in:
2010-06-15 20:09:30 +01:00
parent 4cc436540a
commit e50e4c87aa

View File

@@ -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()