国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

django實現后臺顯示媒體文件

瀏覽:54日期:2024-10-11 09:54:01

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

urlpatterns = [ url(r’^media/(?P<path>.*)$’, serve, {'document_root': MEDIA_ROOT}),]

這樣在后臺上傳媒體文件就能顯示出來。

補充知識:pycharm中用pyinstaller 打包生成 .exe時出現typeerror:expected str,bytes or os.path,not None type解決方法

系統:win10 64位

錯誤提示如下:

Traceback (most recent call last): File 'C:UsersuserDesktopuntitled1venvScriptspyinstaller-script.py', line 11, in <module> load_entry_point(’PyInstaller==3.4’, ’console_scripts’, ’pyinstaller’)() File 'C:UsersuserDesktopuntitled1venvlibsite-packagesPyInstaller__main__.py', line 111, in run run_build(pyi_config, spec_file, **vars(args)) File 'C:UsersuserDesktopuntitled1venvlibsite-packagesPyInstaller__main__.py', line 63, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File 'C:UsersuserDesktopuntitled1venvlibsite- packagesPyInstallerbuildingbuild_main.py', line 838, in main build(specfile, kw.get(’distpath’), kw.get(’workpath’), kw.get(’clean_build’)) File 'C:UsersuserDesktopuntitled1venvlibsite- packagesPyInstallerbuildingbuild_main.py', line 784, in build exec(text, spec_namespace) File '<string>', line 29, in <module> File 'C:UsersuserDesktopuntitled1venvlibsite-packagesPyInstallerbuildingapi.py', line 424, in __init__ strip_binaries=self.strip, upx_binaries=self.upx, File 'C:UsersuserDesktopuntitled1venvlibsite-packagesPyInstallerbuildingapi.py', line 196, in __init__ self.__postinit__() File 'C:UsersuserDesktopuntitled1venvlibsite-packagesPyInstallerbuildingdatastruct.py', line 158, in __postinit__ self.assemble() File 'C:UsersuserDesktopuntitled1venvlibsite-packagesPyInstallerbuildingapi.py', line 273, in assemble pylib_name = os.path.basename(bindepend.get_python_library_path()) File 'C:UsersuserAppDataLocalProgramsPythonPython37libntpath.py', line 214, in basename return split(p)[1] File 'C:UsersuserAppDataLocalProgramsPythonPython37libntpath.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:xxxvenvLibsite-packagesPyInstallerdepend里的bindepend.py,其中xxx為你自己電腦上的路徑,不同的個人電腦路徑可能不太一樣。

然后在pycharm Terminal 運行命令:pyinstaller -F xx.py即可。xx為python文件名。

以上這篇django實現后臺顯示媒體文件就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Django
相關文章:
主站蜘蛛池模板: 江津市| 宁化县| 景东| 那坡县| 扶沟县| 元江| 江川县| 阿拉尔市| 莎车县| 依安县| 亳州市| 获嘉县| 黄平县| 什邡市| 松江区| 南昌县| 唐河县| 甘南县| 衡水市| 集安市| 安丘市| 云和县| 临城县| 麦盖提县| 平谷区| 喀什市| 武胜县| 韩城市| 华安县| 塘沽区| 扬州市| 武宣县| 鲁山县| 波密县| 伊川县| 会泽县| 锦屏县| 垫江县| 禹州市| 体育| 威宁|