Reputation: 5355
Django 1.10 using runserver in development
For some reason, no files can be found in my static directory unless I have it listed as such:
STATIC_URL = 'static/'
if not os.environ.get('DEPLOYED'):
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
But all documentation and everything I have done before says it should be /static/ which makes me think I'm doing something wrong elsewhere. I am using Django's runserver
URLS:
if settings.DEBUG:
from django.conf.urls.static import static
from django.contrib.staticfiles import views
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
I get to the site now by typing localhost:8000/static/index.html
Upvotes: 0
Views: 605
Reputation: 5355
It was a simple misunderstanding. I did what Eugene recommended
findstatic index --verbosity=2
The output was 3 static folders that were not my static folder. I realized I had a basic misunderstanding of STATIC_ROOT and STATICFILES_DIRS. The path to my static folder was not in STATICFILES_DIRS in development.
I added the static folder to STATICFILES_DIRS and I was good. I removed the URL reference as suggested. I had to change STATIC_ROOT to not be that folder... which makes sense because a collectstatic will move everything to the STATIC_ROOT folder for deployment.
Upvotes: 1