The Error
I'm trying to use the django-nested-inline package. It seems like everything works but when I try to create a new Course
with the admin website I get the following error:
TemplateDoesNotExist at /admin/courses/course/5/
admin/edit_inline/stacked-nested.html
But of course, admin/edit_inline/stacked-nested.html
only doesn't exist because there was an error during template rendering:
Error during template rendering
In template C:\...\django\contrib\admin\templates\admin\change_form.html, error at line 62
admin/edit_inline/stacked-nested.html
60 {% block inline_field_sets %}
61 {% for inline_admin_formset in inline_admin_formsets %}
62 {% include inline_admin_formset.opts.template %}
63 {% endfor %}
64 {% endblock %}
As you can see, something messes up when Django tries to render
{% include inline_admin_formset.opts.template %}
My Code
Here's my admin.py
, but I don't think it really has anything to do with the above error:
from django.contrib import admin
from nested_inline.admin import NestedStackedInline, NestedModelAdmin
from courses.models import Course, Skill, Note
class NoteInline(NestedStackedInline):
model = Note
extra = 0
class SkillInline(NestedStackedInline):
model = Skill
extra = 0
inlines = [NoteInline]
class CourseAdmin(NestedModelAdmin):
inlines = [SkillInline]
admin.site.register(Course, CourseAdmin)
And here's my models.py
:
from django.db import models
class Course(models.Model):
course_name = models.CharField(max_length=200)
course_description = models.CharField(max_length=1000, default='Course Description')
course_subject = models.CharField(max_length=200, default='No Subject')
def num_skills(self):
return len(self.skill_set.all())
def __unicode__(self):
return self.course_name
def __str__(self):
return unicode(self).encode('utf-8')
class Skill(models.Model):
course = models.ForeignKey(Course)
skill_name = models.CharField(max_length=200)
skill_description = models.CharField(max_length=1000, default='Skill Description')
def __unicode__(self):
return self.skill_name
def __str__(self):
return unicode(self).encode('utf-8')
class Note(models.Model):
skill = models.ForeignKey(Skill)
note_text = models.CharField(max_length=1000, default='...note text...')
def __unicode__(self):
return self.note_text
def __str__(self):
return unicode(self).encode('utf-8')
Things I've Noticed
- django-nested-inline was updated from 0.3.3 to 0.3.4 two days ago. The updated version "added licence and updated for python 3". I'm using 0.3.4, but also Python 2.7, not Python 3. However, I uninstalled 0.3.4, installed 0.3.3, and tried again. This didn't work and produced the same error. I've since uninstall 0.3.3 and reinstall 0.3.4.
- The admin site and the site itself doesn't crash, just when I try to add a new
Course
via the admin site.