Django Template inheritance causes a bus error

692 views Asked by At

I'm working in a multisite hierarchy in a Django template, whereby I need a master base template (base/base.html), for which I have several master templates extending from, such as base/base_twocol.html. And then I have templates that extend from those templates, such as base/base_twocol_SECTION.

Then I need to have the same set of templates, which will deal with another site, but extending from those templates, such as another_site/base.html, another_site/base_twocol.html, another_site/base_twocol_SECTION.html.

The goal is to have a master set of templates that can be overridden for each site.

So I have something like this:

templates/
    base/
        base.html 
        base_twocol.html           //extends base.html
        base_twocol_SECTION.html   // extends base_twocol.html
    another_site/
        base.html                  //extends base/base.html
        base_twocol.html           //extends base/base_twocol.html
        base_twocol_SECTION.html   //extends base/base_twocol_SECTION.html
    super_cool_site/
        base.html                  //extends base/base.html
        base_twocol.html           //extends base/base_twocol.html
        base_twocol_SECTION.html   //extends base/base_twocol_SECTION.html

I've created my another_site/base.html, and used the syntax {% extends "base.html" %}

However when I run the server, I get a "No data received error" from the browser and "Bus error" from the console.

2

There are 2 answers

2
shrewdbeans On BEST ANSWER

The bus error is being manifested by the naming of the files, because there are two templates of the same name, with one of them trying to extend from the other.

In another_site/base.html, I have {% extends "base.html" %}, but this file is also called base.html.

So basically, I can't have a tempalte called X, and another tempalte called X which extends template X. Perhaps my question wasn't phrased quite right which is why this wasn't picked up on.

The child template needs to have a unique name. I did this for all of my template files and now it works fine.

0
supervacuo On

From a thread in the django-users group:

A bus error occurs due to unaligned memory access, or access to a non existent memory address. In the absence of an actual bug (which others would see), this clearly indicates that one or another of the C libraries used by python conflicts with it.

This could happen if you compiled a C library to use with python, like one of the many python packages that consist of a small C library (mysql and postgresql DB adaptors, PIL, many others), and use it with a different python than it was compiled against.

This is almost certainly nothing to do with your template inheritance. Check your Python and Django installation, reinstalling if necessary. Please also provide more details about your environment and, as Jonas says, the full stack trace.