¿Por qué no puedo hacer que mi directorio estático funcione con django 1.3?
Este problema es muy simple, pero no puedo resolverlo
added to my urlpatterns
url(r'^static/(?P<path>.*)where my main.css es: /home/user/www/site/static/css/main.cs
cuando accedo ahttp: // localhost: 8000 / static /
Obtengo: 404: Aquí no se permiten índices de directorio.
cuando accedo ahttp: // localhost: 8000 / static / css / main.css
Obtuve: 404: 'css / main.css' no se pudo encontrar
¿Qué estoy haciendo mal
Arreglado
url(r'^static/(?P<path>.*)in settings.py
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(CURRENT_PATH, 'static') #=='/home/user/www/site/static'
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/mystatic/'
Como puede ver, lo único que realmente cambié fue de STATIC_URL = '/ static /' a STATIC_URL = '/ mystatic /'
note: cuando llegué ahttp: // localhost: 8000 / mystatic ... obtengo los mismos errores que arriba
Pensé que se suponía que STATIC_URL era '/ static /' para que pudieras usar {{STATIC_URL}} en tus plantillas ... Realmente no entiendo por qué esta corrección funcionó y por qué tuve que hacer el cambio que hizo...
¿Por qué funciona esto?
, 'django.views.static.serve', {'document_root': '/home/user/www/site/static'})
where my main.css es: /home/user/www/site/static/css/main.cs
cuando accedo ahttp: // localhost: 8000 / static /
Obtengo: 404: Aquí no se permiten índices de directorio.
cuando accedo ahttp: // localhost: 8000 / static / css / main.css
Obtuve: 404: 'css / main.css' no se pudo encontrar
¿Qué estoy haciendo mal
Arreglado
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT } ),
in settings.py
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(CURRENT_PATH, 'static') #=='/home/user/www/site/static'
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/mystatic/'
Como puede ver, lo único que realmente cambié fue de STATIC_URL = '/ static /' a STATIC_URL = '/ mystatic /'
note: cuando llegué ahttp: // localhost: 8000 / mystatic ... obtengo los mismos errores que arriba
Pensé que se suponía que STATIC_URL era '/ static /' para que pudieras usar {{STATIC_URL}} en tus plantillas ... Realmente no entiendo por qué esta corrección funcionó y por qué tuve que hacer el cambio que hizo...
¿Por qué funciona esto?
, 'django.views.static.serve', {'document_root': settings.STATIC_ROOT } ),
in settings.py
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(CURRENT_PATH, 'static') #=='/home/user/www/site/static'
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/mystatic/'
Como puede ver, lo único que realmente cambié fue de STATIC_URL = '/ static /' a STATIC_URL = '/ mystatic /'
note: cuando llegué ahttp: // localhost: 8000 / mystatic ... obtengo los mismos errores que arriba
Pensé que se suponía que STATIC_URL era '/ static /' para que pudieras usar {{STATIC_URL}} en tus plantillas ... Realmente no entiendo por qué esta corrección funcionó y por qué tuve que hacer el cambio que hizo...
¿Por qué funciona esto?
, 'django.views.static.serve', {'document_root': '/home/user/www/site/static'})where my main.css es: /home/user/www/site/static/css/main.cs
cuando accedo ahttp: // localhost: 8000 / static /
Obtengo: 404: Aquí no se permiten índices de directorio.
cuando accedo ahttp: // localhost: 8000 / static / css / main.css
Obtuve: 404: 'css / main.css' no se pudo encontrar
¿Qué estoy haciendo mal
Arreglado
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT } ),
in settings.py
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(CURRENT_PATH, 'static') #=='/home/user/www/site/static'
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/mystatic/'
Como puede ver, lo único que realmente cambié fue de STATIC_URL = '/ static /' a STATIC_URL = '/ mystatic /'
note: cuando llegué ahttp: // localhost: 8000 / mystatic ... obtengo los mismos errores que arriba
Pensé que se suponía que STATIC_URL era '/ static /' para que pudieras usar {{STATIC_URL}} en tus plantillas ... Realmente no entiendo por qué esta corrección funcionó y por qué tuve que hacer el cambio que hizo...
¿Por qué funciona esto?