Elastic Beanstalk不加载Django管理静态文件

时间:2018-05-06 21:32:31

标签: django django-admin elastic-beanstalk

我的项目中的特定应用程序中有静态文件,我在配置文件中添加该路由作为EB的静态路由,而且我这样做EB不会为django管理页面加载所需的CSS文件。 我的python.config看起来像:
    option_settings:
  AWS:elasticbeanstalk:容器:蟒蛇:
    WSGIPath:MyProject / wsgi.py
  “AWS:elasticbeanstalk:容器:蟒蛇:staticfiles”:
            / static /:“MyApp / static /”

我收到以下错误:

  

无法加载资源:服务器响应状态为404(未找到)   /static/admin/css/responsive.css:1

1 个答案:

答案 0 :(得分:0)

要告诉Django在哪里存储静态文件,请在settings.py中定义STATIC_ROOT:

class PostListView(LoginRequiredMixin, ListView):
    # ...
    def get_queryset(self):
        queryset = super(PostCreateView).get_queryset()
        return queryset.filter(created_by=self.request.user)

然后输入命令:

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = 'static'
相关问题