Py学习  »  问与答

static目录无法找到?

痴狂的剑 • 8 年前 • 2545 次点击  

setting代码:

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_PATH = os.path.join(BASE_DIR, 'static')

STATIC_URL = '/static/'

STATIC_DIRS = [

    STATIC_PATH,

]

#Template dirs

TEMPLATE_PATH = os.path.join(BASE_DIR, 'template')

TEMPLATE_DIRS = [

    TEMPLATE_PATH,

]

运行之后,提示:

[20/Oct/2015 17:52:36] "GET / HTTP/1.1" 200 999
[20/Oct/2015 17:52:36] "GET /static/csqt.css HTTP/1.1" 404 1628
[20/Oct/2015 17:52:36] "GET /static/images/logo-new.png HTTP/1.1" 404 1661
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/1303
 
2545 次点击  
文章 [ 5 ]  |  最新文章 8 年前
痴狂的剑
Reply   •   1 楼
痴狂的剑    8 年前

@MCC 谢谢,学习了。

MCC
Reply   •   2 楼
MCC    8 年前

@痴狂的剑 这个2回事,具体看文档 https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-STATICFILES_FINDERS

痴狂的剑
Reply   •   3 楼
痴狂的剑    8 年前

@MCC 我也找到原因了,在setting里面,静态文件目录,必须是STATICFILES_DIRS的命名,改成STATIC_DIRS就不行,哥们你这个是动态查找app里面的静态目录文件,这两种相比,是不是你这种效率更好些?

MCC
Reply   •   4 楼
MCC    8 年前
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
痴狂的剑
Reply   •   5 楼
痴狂的剑    8 年前

template 目录是可以正常找到的,但是static目录里的文件就找不到。

发帖怎么上图,不能上传吗,只能用其他空间?

html模板可以显示,图片的位置就是个框框。