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 trialMichael Rodriguez
11,349 Pointsgetting TemplateSyntaxError: 'staticfiles' is not a registered tag library. [Solved]
urls.py file: from . import views from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = [ url(r'^courses/', include(courses.urls)), path('admin/', admin.site.urls), path('', views.hello_world), ]
urlpatterns += staticfiles_urlpatterns()
setting.py file:
STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'assets'), )
layout.html file: {% load static from staticfiles %}
<!doctype html> <html lang="en"> <head> <title>{% block title %}{% endblock %}</title> <link rel="stylesheet" type="text/css" href="{% static 'css/layout.css' %}"> </head> <body> <div class="site-container"> {% block content %} {% endblock %} </div> </body> </html>
2 Answers
Michael Rodriguez
11,349 PointsOk so i fixed my issue. If you are using pycharm and Django 3.0 and get this error in layout.html change {% load static from staticfiles %} to just {% load static %} If you type everything right it should work
Jeff Muday
Treehouse Moderator 28,720 PointsGood catch Michael!
Django 3.0 removed staticfiles
https://docs.djangoproject.com/en/dev/releases/3.0/#features-removed-in-3-0