Fix model json conversion (#108)
* Add all fields when converting model to json * Fix switched image/description in page meta
This commit is contained in:
parent
622a8ef3c2
commit
933c3678d4
@ -228,7 +228,9 @@ class App(Base):
|
|||||||
component = component if isinstance(component, Component) else component(*args)
|
component = component if isinstance(component, Component) else component(*args)
|
||||||
|
|
||||||
# Add the title to the component.
|
# Add the title to the component.
|
||||||
compiler_utils.add_meta(component, title, description, image)
|
compiler_utils.add_meta(
|
||||||
|
component, title=title, image=image, description=description
|
||||||
|
)
|
||||||
|
|
||||||
# Format the route.
|
# Format the route.
|
||||||
route = utils.format_route(path)
|
route = utils.format_route(path)
|
||||||
|
@ -22,6 +22,17 @@ class Model(Base, sqlmodel.SQLModel):
|
|||||||
# The primary key for the table.
|
# The primary key for the table.
|
||||||
id: int = sqlmodel.Field(primary_key=True)
|
id: int = sqlmodel.Field(primary_key=True)
|
||||||
|
|
||||||
|
def dict(self, **kwargs):
|
||||||
|
"""Convert the object to a dictionary.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
kwargs: Ignored but needed for compatibility.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The object as a dictionary.
|
||||||
|
"""
|
||||||
|
return {name: getattr(self, name) for name in self.__fields__}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_all():
|
def create_all():
|
||||||
"""Create all the tables."""
|
"""Create all the tables."""
|
||||||
|
@ -190,7 +190,7 @@ class Var(ABC):
|
|||||||
and hasattr(self.type_, "__fields__")
|
and hasattr(self.type_, "__fields__")
|
||||||
and name in self.type_.__fields__
|
and name in self.type_.__fields__
|
||||||
):
|
):
|
||||||
type_ = self.type_.__fields__[name].type_
|
type_ = self.type_.__fields__[name].outer_type_
|
||||||
if isinstance(type_, ModelField):
|
if isinstance(type_, ModelField):
|
||||||
type_ = type_.type_
|
type_ = type_.type_
|
||||||
return BaseVar(
|
return BaseVar(
|
||||||
|
Loading…
Reference in New Issue
Block a user