Created
May 21, 2014 14:31
-
-
Save jlafon/2f9884a4aabc9483ba52 to your computer and use it in GitHub Desktop.
Default attribute values
This file contains hidden or 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 pynamodb.models import Model | |
from pynamodb.attributes import UnicodeAttribute | |
def make_id(): | |
return somerandomid | |
class Thread(Model): | |
table_name = 'Thread' | |
forum_name = UnicodeAttribute(hash_key=True) | |
another_field = UnicodeAttribute(hash_key=True) | |
def __init__(self, *args, **kwargs): | |
custom_id = make_id() | |
kwargs.setdefault("forum_name", custom_id) | |
kwargs.setdefault("another_field", custom_id) | |
super(Thread, self).__init__(*args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment