Created
May 10, 2016 15:32
-
-
Save timothycrosley/57e590b5a2bf5fa1244b79b72a060bda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from peewee import TextField | |
class BetterUUID(TextField): | |
"""Stores a uuid only defining it if it doesn't already exist""" | |
def db_value(self, value): | |
if not value: | |
value = uuid.uuid4() | |
return value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment