Replies: 1 comment 1 reply
-
I think the problem is that you didn't save your object. For example, if you try >>> foo = Band()
>>> foo.to_dict()
{'id': <piccolo.querystring.QueryString at 0x105fe4460>,
'name': '',
'manager': None,
'popularity': 0} Which is basically the same as what you got. But if you do the >>> foo = Band()
>>> await foo.save()
>>> foo.to_dict()
{'id': 4, 'name': '', 'manager': None, 'popularity': 0} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I've created a blacksheep project and I'm trying to integrate piccolo into it. I have created a sample project with
piccolo asgi new
for reference. I have created a piccolo app, and added it to the APP_REGISTRY in piccolo_conf.py and inside the app I have defined a model that looks like this:I have created pydantic models using the create_pydantic_model from
piccolo_api.crud.serializers
and created UrlMapPartial and UrlMapOut. In my create post endpoint, I am setting the default values for all the fields on UrlMap, and doing a urlmap.save(). But when I try andreturn UrlMapOut(**urlmap.to_dict())
, I get the following error stack:When I dump out my urlmap variable it looks like this:
It seems like the field 'id' instead of being automatically set to an integer, is being given this QueryString object instance. Could someone please tell me the right way to do this? I've gone through the docs, and it just says you save and it should work. I'm using sqlite database btw.
Beta Was this translation helpful? Give feedback.
All reactions