Reputation: 33
I am learning pydantic-redis,and I tried to modify the example at https://github.com/sopherapps/pydantic-redis
by adding a new field new_field: dict = {}
as follows
class Book(Model):
_primary_key_field: str = 'title'
title: str
author: str
published_on: date
in_stock: bool = True
new_field: dict = {}
when I run the example it says (in the end):
value is not a valid dict (type=type_error.dict)
I have also tried other types, like new_field: List[int] = [8]
(and then importing typing.List)
On the other hand, when I add a new field with a primitive type like int, everything works fine.
What have I missed?
Best regards
Upvotes: 1
Views: 144
Reputation: 33
I asked the author, and it turned out it was a bug. Now it's fixed, and my example works! Just install the latest version, 0.1.2, and there is a modified example with some nested data. Works fine :-)
BR, David
Upvotes: 1