-
Notifications
You must be signed in to change notification settings - Fork 53
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: custom relation field #521
Comments
Somehow this saves the optimization and at the same moment returns all required data:
I don't understand how it all works. |
I found thys syntax in admin demo source code:
I belive this can help to change list view. |
Is there any way to set representation html template for detail view also? |
I made _detail_repr |
You can simply override the detail template for this specific field. You can find more information on https://jowilf.github.io/starlette-admin/advanced/custom-field/?h=custom#detail-page Also, I noticed that you are currently using an outdated version of starlette-admin. I recommend upgrading to the latest version. |
The field names must be unique per view |
Is your feature request related to a problem? Please describe.
I want to make custom relation field so i can set custom render_function_key and custom display template.
Describe the solution you'd like
A clear and concise description of what you want to happen.
Something like this in list:
and something like this in detail:
Describe alternatives you've considered
If i trying to use StringField as base class:
It leads to this api response:
GET: http://127.0.0.1:8000/admin/api/desk?skip=0&limit=20&order_by=id%20asc:
Reponse:
As you can see it resolving "notes" field (relation of a relation) and showing it like text (serializing func thinks it string field).
This is problem because it overloads backend by resolving a lot of related records.
And it might be not a problem if there is no a lot of relations, but if there a long chain of relations it starting resolving literally all databse which leads to crash of worker and even cycling of resolving records which leads to endless fetching to the database (and blocking it) until worker crashing and restarts by itself.
I found out that i can change "serialize" function to exclude this field:
but this method is not allowing me to use relations information in detail view.
This method leads to overloading database in detail view:
How i can change serialize def so it stop to resolving in some moment? Or it will be even better if there is another more correct way to customize relation field display?
The text was updated successfully, but these errors were encountered: