找到Django映像但未删除

时间:2018-07-07 10:32:04

标签: python html django

我正在使用Django视图在文件夹中显示一些图像。该程序可以搜索文件,但无法显示,所有图像都有404错误。

views.py

$data = User::whereHas('roles' => function($query) use ($team) {
    $query->where('role_code', '=', $team)
})->get();

html

import os
from datetime import datetime

now = datetime.now()
image_now = now.strftime("%d_%m_%Y")
image_list=[]
app_static_dir = os.path.join(os.path.join(os.path.join(os.path.join(settings.BASE_DIR,'index'),'static'),'{}'.format(image_now)),'demo')
for file in os.listdir(app_static_dir):
    if file.endswith("1_plate.jpg"):
        image_list.append(file)

enter image description here

1 个答案:

答案 0 :(得分:0)

使用{% static %} template tag来添加正确的静态根目录。

var obj = {
"myValues": [
 {
    "begin": 514,
    "end": 597,
    "type": "cars"
 },
 {
    "begin": 514,
    "end": 597,
    "type": "shoes"
 }]}
for (var item in obj.myValues) {
  var type = obj.myValues[item].type;

  if (type == 'shoes') {
      console.log('deleted');
      delete obj.myValues[item].type;
  }
}

console.log(obj);

您还必须按照docs中所述正确配置staticfiles应用:

Managing static files (e.g. images, JavaScript, CSS)