lundi 3 août 2015

How do you store list in Peewee model?

I created a model using the peewee ORM that looks like this:

class Person(Model):
username = CharField(max_length=255, unique=True)
badges = ??? # No list field?

class Meta:
    database = db

This is the data that I will store:

people = [
{'username': 'user1', 'badges': ['badge 1','badge 2']},
{'username': 'user2', 'badges': ['badge 1', 'badge 2', 'badge 3']},
{'username': 'user3', 'badges': ['badge 1', 'badge 2', 'badge 3', 'badge 4']},
]  

I wanted to store my badges in a list of strings, but there isn't a list field. How else can I do something like this?

Aucun commentaire:

Enregistrer un commentaire