URL로 APPNAME을 추가에장고 : STATIC_URL는 내가 지금처럼 내 정적 설정을 구성한
STATIC_ROOT = os.path.join(SITE_ROOT, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
('js', os.path.join(STATIC_ROOT, 'js')),
('css', os.path.join(STATIC_ROOT, 'css')),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
이러한 내 urls.py
: 그것은 URL localhost:8000/login
매우 잘 작동
urlpatterns = patterns('',
url(r'^login/?$', login, name='login'),
url(r'^logout/?$', logout_then_login, name='logout'),
url(r'^profile/(?P<user_id>\d+)$', 'profiles.views.detail'),
url(r'^profile/edit$', 'profiles.views.edit'),
)
urlpatterns += staticfiles_urlpatterns()
하지만, 내 profiles
응용 프로그램에서 처리하는 localhost:8000/profile/edit
사이트에 도착하면 은 /static/...
에서 /profile/static/...
으로 모든 경로를 변경하므로 내 javascript 및 스타일 시트는 변경되지 않습니다. 더 이상 발견되지 않았다.
내가 뭘 잘못 했니?
편집 : 여기에있을 것입니다 내 base.html
당신이 당신의 urls.py
에서 다음 줄을 제거하려고 내장 developement에 서버 장고를 사용하고 있기 때문에
<!DOCTYPE html>
<html>
<head>
<title>Neighr{% block title %}{% endblock %}</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.min.js"></script>
{% block script %}{% endblock %}
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
'staticfiles_urlpatterns()':
편집
settings.py
경우이 같은 시도? 이게 뭐야? –@ Thibault J : [this] (https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-development)에 따르면 정적 파일을 제공하는 데 필요한 추가 기능 개발 환경에서. – Lanbo
당신이 준 링크에서 언급했듯이, django 내장 서버를 사용하지 않는 경우에만 유효합니다. 그렇지 않으면 정적 파일이 자동으로 제공됩니다. 어떤 서버를 사용하고 있습니까? –