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 trialGreg Kaleka
39,021 PointsTemplateSyntaxError at / Invalid block tag on line 9: 'static'. Did you forget to register or load this tag?
Not sure why I'm getting this error. My code is identical to Kenneth's, except that I used a list instead of tuple for STATICFILES_DIRS
, because I'm using a newer version of Django.
I'm using my local environment rather than Workspaces.
Here are just the pertinent parts of my files for this lesson:
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'assets'),
]
urlpatterns = [
url(r'^courses/', include('courses.urls')),
url(r'^admin/', admin.site.urls),
url(r'^$', views.homepage),
]
urlpatterns += staticfiles_urlpatterns()
%{ load static from staticfiles %}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="{% static 'css/layout.css' %}">
1 Answer
Ryan S
27,276 PointsHi Greg,
In layout.html
on line 1, it seems you have the incorrect syntax for the opening template tag. You have %{
when it should be {%
.
This is causing the template error on line 9 because the static
template tag hasn't been successfully loaded.
Greg Kaleka
39,021 PointsGreg Kaleka
39,021 Pointsit's always the little things that get you, isn't it?
Thanks!
Ryan S
27,276 PointsRyan S
27,276 PointsFor sure. I personally find the % key and curly braces combination to be a little awkward. I'm always stumbling on typos in my template tags.