时间:2021-05-22
1、在全局settings文件中配置
```MEDIA_URL = '/media/'MEDIA_ROOT = os.path.join(BASE_DIR, 'media')2、 在全局的urls文件中:
from MxShop.settings import MEDIA_ROOT #导 入配置文件中的配置
from django.views.static import serve
这样在后台上传媒体文件就能显示出来。
补充知识:pycharm中用pyinstaller 打包生成 .exe时出现typeerror:expected str,bytes or os.path,not None type解决方法
系统:win10 64位
错误提示如下:
Traceback (most recent call last): File "C:\Users\user\Desktop\untitled1\venv\Scripts\pyinstaller-script.py", line 11, in <module> load_entry_point('PyInstaller==3.4', 'console_scripts', 'pyinstaller')() File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\__main__.py", line 111, in run run_build(pyi_config, spec_file, **vars(args)) File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "C:\Users\user\Desktop\untitled1\venv\lib\site- packages\PyInstaller\building\build_main.py", line 838, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "C:\Users\user\Desktop\untitled1\venv\lib\site- packages\PyInstaller\building\build_main.py", line 784, in build exec(text, spec_namespace) File "<string>", line 29, in <module> File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\building\api.py", line 424, in __init__ strip_binaries=self.strip, upx_binaries=self.upx, File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\building\api.py", line 196, in __init__ self.__postinit__() File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__ self.assemble() File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\building\api.py", line 273, in assemble pylib_name = os.path.basename(bindepend.get_python_library_path()) File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\ntpath.py", line 214, in basename return split(p)[1] File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\ntpath.py", line 183, in split p = os.fspath(p) TypeError: expected str, bytes or os.PathLike object, not NoneType解决方法:
在github这个页面上https://github.com/Loran425/pyinstaller/tree/14b6e65642e4b07a4358bab278019a48dedf7460
下载所有文件,解压后找到文件夹PyInstaller里的bindepend.py文件,然后copy替换C:\xxx\venv\Lib\site-packages\PyInstaller\depend里的bindepend.py,其中xxx为你自己电脑上的路径,不同的个人电脑路径可能不太一样。
然后在pycharm Terminal 运行命令:pyinstaller -F xx.py即可。xx为python文件名。
以上这篇django实现后台显示媒体文件就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
Premiere导入了媒体剪辑后,如果后期对电脑中的媒体文件进行了重命名或是移动了媒体文件的位置。在Premiere中加载媒体时就会弹出“缺少这些剪
从wordpress后台媒体库上传的媒体文件,不像文章那样可以给它指定分类和标签,但是很多时候我们又需要这样的功能,如一些下载站、图片站等。媒体编辑页面的原始状
答:可以通过以下方式打开媒体文件:第1种方式:从资源管理器打开。1)有文件关联时,鼠标左键双击已经关联的媒体文件;2)有文件关联时,鼠标右键单击已经关联的媒体文
回复图片、音频、视频消息都是需要media_id的,这个是需要将多媒体文件上传到微信服务器才有的。将多媒体文件上传到微信服务器,以及从微信服务器下载文件,可以参
综述所有内容的访问变化见下图:外部媒体文件的扫描,读取和写入最容易被踩坑的应该是,对外部媒体文件,照片,视频,图片的读取或写入。扫描首先是扫描。扫描依然是使用q