python - pythonanywhere django static files are not collected from application
问题描述
The problem is that static files from Django app are not being collected in pythonanywhere. After the command
python manage.py collectstatic
In the directory
/home/user/user.pythonanywhere.com/static
Only the admin folder appears. settings.py:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp'
]
Css file location:
+---myapp
| +---static
| | \---myapp
| | \---css
| | \---myapp.css
When I run the command python manage.py collectstatic in my local command line, static files from the application are collected, the problem is in pythonanywhere.
All actions are standard, I did everything strictly according to the guide, I cannot understand what's the matter. Thanks a lot
I have read all the articles on this topic on pythonanywhere and everything I found on stackoverflow and in the documentation, but nothing helps to solve the problem.
https://help.pythonanywhere.com/pages/DjangoStaticFiles
https://help.pythonanywhere.com/pages/DebuggingStaticFiles/
https://help.pythonanywhere.com/pages/StaticFiles
UPD: BASE_DIR = Path(file).resolve().parent.parent
Bash console text output:
You have requested to collect static files at the destination location as specified in your settings: /home/user/user.pythonanywhere.com/static This will overwrite existing files! Are you sure you want to do this? Type 'yes' to continue, or 'no' to cancel: yes 0 static files copied to '/home/user/user.pythonanywhere.com/static', 132 unmodified.
The contents of /home/user/user.pythonanywhere.com/static directory after collectstatic command:
+---admin
| +---css
| +---fonts
| +---img
| +---js
解决方案
推荐阅读
- python - Pip 正在尝试使用与安装的不同版本的 python
- swift - 如何将observeDataEventType.value 的firebase 快照转换为observeSingleEvent?
- javascript - 如何从 JavaScript 中的 JSON 有效负载获取所有匹配属性
- python - 如何在pytorch中包含一个属性让用户决定是否使用GPU?
- java - 生成查找表
- javascript - 如何修复 000webhost 上的图标错误
- javascript - 如何在 Nuxt.js 中使用官方 Swiper.js 作为插件
- r - 在 Shiny 应用程序中创建数据表时出错
- laravel - 如何在laravel中获取请求和响应的大小
- android - 在 Android 的 ViewPager2 中检测滑动越界