You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You should be able to pass the underlying value, so course = await Course.objects.create(department=1) should work.
What happens in your case?
I see this error: AttributeError: 'int' object has no attribute 'get'
post_info = {
"title": "My post",
"link": 1
}
self.post = await Post.objects.create(**post_info)
# Models
class Post(ormar.Model):
id: int = ormar.Integer(primary_key=True)
title: str = ormar.String(max_length=500)
link: PageLink = ormar.ForeignKey(PageLink, related_name='posts', ondelete="CASCADE")
class Meta(BaseMeta):
tablename = 'posts'
class PageLink(ormar.Model):
id: int = ormar.Integer(primary_key=True)
value: str = ormar.String(max_length=2048)
country: str = ormar.String(max_length=1000)
def __str__(self):
return f'{self.id}'
class Meta(BaseMeta):
tablename = 'pagelinks'
Stack:
File ".../venv/lib/python3.9/site-packages/ormar/queryset/queryset.py", line 1018, in create
new_kwargs = self.model.prepare_model_to_save(new_kwargs)
File ".../venv/lib/python3.9/site-packages/ormar/models/mixins/save_mixin.py", line 40, in prepare_model_to_save
new_kwargs = cls.substitute_models_with_pks(new_kwargs)
File ".../venv/lib/python3.9/site-packages/ormar/models/mixins/save_mixin.py", line 130, in substitute_models_with_pks
model_dict[field] = field_value.get(target_pkname)
AttributeError: 'int' object has no attribute 'get'
I see this error:
AttributeError: 'int' object has no attribute 'get'
Stack:
Originally posted by @bilyalov in #262 (reply in thread)
The text was updated successfully, but these errors were encountered: