Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLogesh Jayaraman
445 PointsStatic files
I did exactly as mentioned in the course for adding the static files. But i am getting the error as
NameError at /
name 'staticfiles_urlPatterns' is not defined
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.8.3
Exception Type: NameError
Exception Value:
name 'staticfiles_urlPatterns' is not defined
2 Answers
Chris Freeman
Treehouse Moderator 68,454 PointsDid you import it?
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
Logesh Jayaraman
445 PointsThanks Chris. I did do the import. It is the issue with the spaces. But i have another problem in accessing the images,CSS and js files.
I had updated the settings.py as
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR ,'assets'),
)
Actual path for images is c:\gt\assets\images
Actual path for js is c:\gt\assets\js
when access the http://127.0.0.1:8000, the image and JS path is showing as http://127.0.0.1/home/css/bootstrap.min.css Failed to load resource: the server responded with a status of 404 (Not Found) http://127.0.0.1:8000/images/home/logo1.png Failed to load resource: the server responded with a status of 404 (NOT FOUND)
Which are wrong.
[MOD: edited formatting -cf]
Chris Freeman
Treehouse Moderator 68,454 PointsWhat is the Django template line used to reference these assets?
Have you tried entering the URL directly into the browser? Try: http://127.0.0.1/static/images/logo1.png
, etc.