Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: #550

Open
samearcher opened this issue Jun 14, 2024 · 0 comments
Open

Enhancement: #550

samearcher opened this issue Jun 14, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@samearcher
Copy link

Add support for SQLModel Alias.

Suggest adding something like the below code in starlette_admin/contrib/sqlmodel/view.py. This automatically changes the label for columns to the alias parameter in SQLModel.

Describe the solution you'd like

    async def _configs(self, request: Request) -> Dict[str, Any]:
        locale = get_locale()
        fields = [f.dict() for f in self.get_fields_list(request)]
        for n, field in enumerate(fields):
            for model_field in self.model.__fields__.values():
                if model_field.name == field["name"]:
                    fields[n]['label'] = model_field.alias
        return {
            "label": self.label,
            "pageSize": self.page_size,
@samearcher samearcher added the enhancement New feature or request label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant