Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TemplateSyntaxError while following Heroku Python tutorial

Brand new to using Heroku and I've already hit a roadblock while following the Python tutorial. Every step was pretty straightforward up until provisioning a database. After performing heroku run python manage.py migrate I should be able to see the database after adding /db to the end of the URL, but instead I'm sent to an error page, which looks like this:

TemplateSyntaxError at /db/
'staticfiles' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
i18n
l10n
log
static
tz
Request Method: GET
Request URL:    https://morning-oasis-00207.herokuapp.com/db/
Django Version: 3.0
Exception Type: TemplateSyntaxError
Exception Value:    
'staticfiles' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
i18n
l10n
log
static
tz
Exception Location: /app/.heroku/python/lib/python3.7/site-packages/django/template/defaulttags.py in find_library, line 1025
Python Executable:  /app/.heroku/python/bin/python
Python Version: 3.7.3
Python Path:    
['/app/.heroku/python/bin',
 '/app',
 '/app/.heroku/python/lib/python37.zip',
 '/app/.heroku/python/lib/python3.7',
 '/app/.heroku/python/lib/python3.7/lib-dynload',
 '/app/.heroku/python/lib/python3.7/site-packages']
Server time:    Wed, 11 Dec 2019 23:17:58 +0000

I've literally followed the steps exactly, one after another, so I'm kind of at a loss here. I'd skip past this, but I need to use a database for a project I'm going to be working on and I'd like to know how to avoid this in the future. I've looked at several other similar discussions here, but didn't see anything specific to the tutorial. Any help would be appreciated.

like image 421
dylosaur Avatar asked Dec 11 '19 23:12

dylosaur


1 Answers

Had the same problem here as well. It seems like the staticfiles template tag libraries were updated recently in Django 3.0.0 (in which staticfiles was deprecated), and Heroku probably didn't update the tutorial files.

Go to your local app directory (created from cd python-getting-started) and find settings.py (python-getting-started\gettingstarted\settings.py). Scroll to the bottom and change STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') to STATIC_ROOT = os.path.join(BASE_DIR, 'static').

Go to the template database html file found in python-getting-started\hello\templates\db.html and change {% load staticfiles %} to {% load static %}

Go to the root folder and rename the static files folder from staticfiles to static

Hope this helps. Make sure to update your changes.

like image 167
Austin Zhao Avatar answered Nov 09 '22 09:11

Austin Zhao