python - How overwrite Django Admin readonly FileFields HREF url
问题描述
I have a Django
project in production on Apache
and I've made a model with file that is uploaded to custom path. Now I need to change it's representation in Django
admin details. My FileField
in admin is readonly
and I want that it only shows a correct link to open the file in a new tab.
The problem is that I have alias in Apache
and the current link showed in the admin is for example:
/var/www/html/moeaforhdl/moeaforhdlweb/uploads/uploaded_c_files/194/extracted_dfg.json
Screenshot:
But when I click to open the file it tries to open this URL:
http://201.174.122.25/moeaforhdlweb/uploads/var/www/html/moeaforhdl/moeaforhdlweb/uploads/uploaded_c_files/194/extracted_dfg.json
when the correct URL to open the file is:
http://201.174.122.25/moeaforhdlweb/uploads/uploaded_c_files/194/extracted_dfg.json
I need to remove this part when users click on the link in admin forms and details:
/var/www/html/moeaforhdl/moeaforhdlweb/uploads
How can I overwrite this URL in admin panel, por example in admin.py? Thank you so much.
解决方案
推荐阅读
- google-chrome - 禁用 Chrome 后如何在 Chrome 中启用网络安全?
- amazon-web-services - 在本地获取 sagemaker 容器
- javascript - Youtube 链接 src
- openapi - 引用组件属性的 OpenAPI 路径参数
- sql - Azure 可用备份显示“未找到数据库”
- python - 如何在 3D 图像上绘制坐标并显示它
- sql - 如何使用子查询中的子字符串更新和设置列值?
- javascript - 如何在正则表达式搜索中使用正斜杠?
- angular - 将 Angular 应用程序与 ReactJS 应用程序连接起来?
- r - 如何更快地数值求解 R 中的 ODE