Search code examples
djangootree

b' at start of line - error in django template parsing


I'm trying to follow the public goods tutorial for oTree, but my templates are giving syntax errors. I'm using vim to edit (and in this case create) the templates, but when I try to run otree resetdb It returns the following error:

SystemCheckError: System check identified some issues:

ERRORS:
public_goods_tutorial: (otree.E008) Template syntax error in /[obfuscated]/oTree/public_goods_tutorial/templates/public_goods_tutorial/Contribute.html

   1 | b''
   2 | b'{% extends "global/Page.html %}'
-------^
   3 | b'{% load staticfiles otree_tags %}'
   4 | b''
   5 | b'{% block title %} Contribute {% endblock %}'
   6 | b''
   7 | b'{% block content %}'

Error: Could not parse the remainder: '"global/Page.html' from '"global/Page.html'

It seems the template linter/parser is choking on the newline/carriage return character at the start of the line (to be clear - the b' characters are "appearing out of nowhere" - they do not appear in the file when I am editing in vim.

Having run through the simple survey tutorial and edited template files in that, this problem did not manifest itself. The error is specifically happening on a new file I created rather than one created by otree startapp (though that may just be coincidence because it is alphabetically first?)

I've checked and both encoding and fileencoding for this file is set to utf-8, which the documentation seems to suggest is the django default.

What could be causing my error and how can I address it?


Solution

  • Your template is missing a closing double-quote after 'global/Page.html'. You want:

    {% extends "global/Page.html" %}