collectstatic不会忽略指定的文件

时间:2019-04-14 18:53:44

标签: django

我在弄清楚如何管理我的scss文件时遇到了一些麻烦。这是我的文件夹结构:

 manage.py
├── myWebsite
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── projects
│   ├── admin.py
│   ├── apps.py
│   ├── __init__.py
│   ├── migrations
│   │   └── __init__.py
│   ├── models.py
│   ├── static
│   │   └── projects
│   │       └── css
│   │           ├── index.css
│   │           ├── scss
│   │           │   └── survey.scss
│   │           └── tribute.css
│   ├── templates
│   │   └── projects
│   │       ├── base.html
│   │       ├── documentation.html
│   │       ├── index.html
│   │       ├── portfolio.html
│   │       ├── product.html
│   │       ├── survey.html
│   │       └── tribute.html
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── requirements.txt
└── staticfiles
    └── projects
        └── css
            └── scss
                ├── survey.css
                └── survey.css.map

我想将.scss文件保存在每个应用程序的static / {app_name} / css / scss文件夹中。稍后将它们编译在项目根目录下的staticfiles文件夹中。该文件夹是collectstatic的根目录,该目录在服务器(AWS EB)上部署时运行。

 02_collectstatic:
    command: "source /opt/python/run/venv/bin/activate && python manage.py collectstatic --noinput"

由于我使用的是Django 2.2,因此应该可以忽略collectstatic收集的.scss文件,但似乎无法正常工作,我尝试过:

python manage.py collectstatic --noinput -i projects/static/projects/css/scss

编辑:这是我得到的那种错误:

Activity execution failed, because: usage: manage.py collectstatic [-h] [--noinput] [--no-post-process]
  [-i PATTERN] [-n] [-c] [-l]
  [--no-default-ignore] [--version]
  [-v {0,1,2,3}] [--settings SETTINGS]
  [--pythonpath PYTHONPATH] [--traceback]
  [--no-color] [--force-color]
  manage.py collectstatic: error: unrecognized arguments: /projects/static/projects/css/scss
   (ElasticBeanstalk::ExternalInvocationError) 

2 个答案:

答案 0 :(得分:1)

我认为您在使用-i时指向错误的路径。您需要从静态目录根目录而不是项目根目录中找到路径。例如,如果您的静态目录为:

STATICFILES_DIRS = [
    os.path.join(APPS_DIR, "static"),  # where projects is the apps directory
]
# OR if you are using django-cookie-cutter
# STATICFILES_DIRS = [str(APPS_DIR.path("static"))]

然后,像这样更新代码:

 python manage.py collectstatic --noinput -i projects/css/scss

答案 1 :(得分:0)

遵循Django 2.2 Release Notes

  

将路径匹配添加到collectstatic script getItem{ input index = 0; plot output = index * index; } script test{ def total = fold index = 0 to 10 with accumulator = 0 do accumulator + getItem(index);########## Error: No such variable: index } 选项,以便可以使用import time import random print ('You suddenly jolt up from the sleeping bag, awoken by the howling of nearby wolves.\nYou are cold, shivering and starving, and the few things that are still visible,\nare lit up only by the moon, and notice you are in the middle of a forest.\n') ch1 = str(input(' Do you: \nA: Use your hands to search around\nB: Sleep again until morning\nC: Get up, and attempt to run away from the wolves in the dark:\n')) responsesA = [ 'You found a torch!', 'You did not find anything.' ] responsesB = [ 'You fell asleep again cold and hungry.', 'You are unable to sleep.' ] responsesC = [ 'You start running as fast as you can and successfuly escape!', 'You trip and injure knee.' ] if ch1 in ['A']: print (random.choice(responsesA)) if ch1 in ['B']: print (random.choice(responsesB)) if ch1 in ['C']: print (random.choice(responsesC)) 之类的模式。

--ignore
相关问题