Values instance has no attribute 'default_reference_context'

I was just editing some reStructuredText content for my website when Django threw a strange error at me.

Values instance has no attribute 'default_reference_context'

What was really bizarre is that exactly the same rst content could be published as HTML just fine in a test script:

from docutils.core import publish_parts
rst = 'real content here'
print publish_parts(rst, writer_name='html')['html_body']

I couldn't find anything relevant anywhere on the internet either. After some trial and error I managed to find the source of the problem:

`hyperlink <http://example.com>`

Did you spot the error? The trailing underscore is missing, a valid link would look like:

`hyperlink <http://example.com>`_

I still have no idea why the same code would raise an exception inside Django but work stand-alone (but of course generate unwanted markup). Anyway, problem solved for me.

Updates: other sources for the error

`foo`

Renders as <cite> outside of Django.

Solved

The problem has existed for five years in Django core, see #6681. A simple solution is to disable the admindocs app. Yes, the app messes with the docutils settings project-wide.

0 comments

Start a new thread

Cancel reply
Markdown. Syntax highlighting with <code lang="php"><?php echo "Hello, world!"; ?></code> etc.