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
...
<tr><td>{{ label }}</td>
{% set value, formatted_value = model_view.get_detail_value(model, name) %}
{% if name in model_view._relation_names %}
{% if is_list( value ) %}
<td>
{% for elem, formatted_elem in zip(value, formatted_value) %}
<ahref="{{ model_view._build_url_for('admin:details', request, elem) }}">({{ formatted_elem }})</a>
{% endfor %}
</td>
{% else %}
{% if name in model_view.excluded_relations_names %} <!-- NEW CHECKS HERE --><td>{{ formatted_value }}</td>
{% else%}
<td><ahref="{{ model_view._url_for_details_with_prop(request, model, name) }}">{{ formatted_value }}</a></td>
{% endif %}
{% endif %}
{% else %}
<td>{{ formatted_value }}</td>
{% endif %}
</tr>
...
Describe alternatives you considered
I found one way to show field as a normal text, without any links:
Add some custom field to column_details_list
Bind this field to related model
Create a label for this custom field
classUserAdmin(ModelView, model=User):
name="User"name_plural="Users"column_list= ["id", "name"]
column_details_list= [
"id",
"name",
"age",
"address_field"# some custom field name
]
column_formatters_detail= {
"address_field": lambdam, a: m.address
}
column_labels= {
"address_field": "address"
}
What if you have much more fields in UserModel? If you want add a custom field to column_details_list, you should explicitly specify all other fields.
Looks like a long workaround.
Additional context
No response
The text was updated successfully, but these errors were encountered:
``column_exclude_list: List of columns or column names to be excluded in the list page.
` `column_details_exclude_list`: List of columns or column names to be excluded in the details page.`
Checklist
Is your feature related to a problem? Please describe.
I want to mark some relative fields so that they don't appear as links in the UI.
For example, I have User and Address models (some unnecessary details of the description of sqlalchemy models was omitted):
Also I want create only UserAdmin model
On User`s details page I will see the address field as a link leading to an 404 page (because I didn't create AddressAdmin model).
I want to mark address field as a simple text, without any links
Describe the solution you would like.
Add new ModelView attribute, called
excluded_relations_names
(for example)add some conditions in details.html
Describe alternatives you considered
I found one way to show field as a normal text, without any links:
What if you have much more fields in UserModel? If you want add a custom field to column_details_list, you should explicitly specify all other fields.
Looks like a long workaround.
Additional context
No response
The text was updated successfully, but these errors were encountered: