Skip to content

Instantly share code, notes, and snippets.

@timothycrosley
Created May 10, 2016 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timothycrosley/57e590b5a2bf5fa1244b79b72a060bda to your computer and use it in GitHub Desktop.
Save timothycrosley/57e590b5a2bf5fa1244b79b72a060bda to your computer and use it in GitHub Desktop.
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