diff --git a/docs/changelog/index.md b/docs/changelog/index.md index cc1c8fd1..3b23c248 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.8.0] - 2023-04-09 + +### Added + +* Add extension to autovalidate SQLAlchemy data with pydantic by [@jowilf](https://github.com/jowilf) + in [#144](https://github.com/jowilf/starlette-admin/pull/144) +* Make `_extract_fields()` method in BaseModelView public and renamed + to [get_fields_list()][starlette_admin.views.BaseModelView.get_fields_list] by [@jowilf](https://github.com/jowilf) + in [#148](https://github.com/jowilf/starlette-admin/pull/148) +* Add support for custom object representations in the admin interface with `__admin_repr__` + and `__admin_select2_repr__` by [@jowilf](https://github.com/jowilf) + in [#152](https://github.com/jowilf/starlette-admin/pull/152). The documentation can be + found [here](../tutorial/configurations/modelview/#object-representation) + +### Internals + +* Enhance code quality with additional ruff rules by [@jowilf](https://github.com/jowilf) + in [#159](https://github.com/jowilf/starlette-admin/pull/159) + ## [0.7.0] - 2023-03-24 ### Added diff --git a/docs/images/tutorial/configurations/modelview/object_text_representation.png b/docs/images/tutorial/configurations/modelview/object_text_representation.png new file mode 100644 index 00000000..56e763f1 Binary files /dev/null and b/docs/images/tutorial/configurations/modelview/object_text_representation.png differ diff --git a/docs/images/tutorial/configurations/modelview/select2_customization.png b/docs/images/tutorial/configurations/modelview/select2_customization.png new file mode 100644 index 00000000..28e70297 Binary files /dev/null and b/docs/images/tutorial/configurations/modelview/select2_customization.png differ diff --git a/docs/tutorial/configurations/modelview/index.md b/docs/tutorial/configurations/modelview/index.md index 6e65c88d..6306cbe7 100644 --- a/docs/tutorial/configurations/modelview/index.md +++ b/docs/tutorial/configurations/modelview/index.md @@ -152,18 +152,22 @@ It is a special method that can be defined in a model class to customize the obj interface. By default, only the value of the object's primary key attribute is displayed. However, by implementing `__admin_repr__`, you can return a string that better represents the object in the admin interface. -For example, the following implementation for a `User` model will display the user's full name instead of their primary -key in the admin interface: +!!! Example + For example, the following implementation for a `User` model will display the user's full name instead of their primary + key in the admin interface: -```python -class User: - id: int - first_name: str - last_name: str + ```python + class User: + id: int + first_name: str + last_name: str + + async def __admin_repr__(self, request: Request): + return f"{self.last_name} {self.first_name}" + ``` + + ![Custom Object representation](../../../images/tutorial/configurations/modelview/object_text_representation.png){ width="200" } - def __admin_repr__(self, request: Request): - return f"{self.last_name} {self.first_name}" -``` ### `__admin_select2_repr__` @@ -183,14 +187,18 @@ fields. Template("Hello {{name}}", autoescape=True).render(name=name) ``` -Here is an example implementation for a `User` model that includes the user's name and photo: +!!! Example -```python -class User: - id: int - name: str - photo_url: str + Here is an example implementation for a `User` model that includes the user's name and photo: - def __admin_select2_repr__(self, request: Request) -> str: - return f'