0

I followed the qblog tutorial, using python 2.7.10 and django 1.9.5.

When i enter the admin's blog interface, and clicked add blog entry, then it shown me below:

TemplateDoesNotExist at /admin/blog/entry/add/
django_markdown/editor_init.html

but i have installed django-markdown already. I would like to show the code below:

models.py:

class Entry(models.Model):
    title = models.CharField(max_length=200)
    body = MarkdownField()
    slug = models.SlugField(max_length=200, unique=True)
    publish = models.BooleanField(default=True)
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)
    tags = models.ManyToManyField(Tag)

    objects = EntryQuerySet.as_manager()

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse("entry_detail", kwargs={"slug": self.slug})

    class Meta:
        verbose_name = "Blog Entry"
        verbose_name_plural = "Blog Entries"
        ordering = ["-created"]

admin.py:

from django.contrib import admin
from . import models
from django_markdown.admin import MarkdownModelAdmin
from django_markdown.widgets import AdminMarkdownWidget
from django.db.models import TextField


class EntryAdmin(MarkdownModelAdmin):
    list_display = ("title", "created")
    prepopulated_fields = {"slug": ("title",)}
    # Next line is a workaround for Python 2.x
    formfield_overrides = {TextField: {'widget': AdminMarkdownWidget}}

admin.site.register(models.Entry, EntryAdmin)
admin.site.register(models.Tag)

qblog/urls.py:

from django.conf.urls import patterns, include, url
from django.contrib import admin
import settings

urlpatterns = patterns(
    '',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^markdown/', include("django_markdown.urls")),
    url(r'^', include('blog.urls')),
)

if settings.DEBUG:
    from django.conf.urls.static import static
    urlpatterns += static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)
Peter Tsung
  • 915
  • 2
  • 10
  • 20

1 Answers1

0

You need to add the editor_init.html file in your project.

If your project root is project/ there should be a directory called templates in there. If that directory does not exist, create it (so the path would be project/templates).

Place the editor_init.html file in this directory and everything should work.

You can find more information about setting up templates here and in the django docs.

Community
  • 1
  • 1
Bono
  • 4,757
  • 6
  • 48
  • 77
  • bad answer. here a template of a library is missing. the reason is somewhere else and this is just a diry hack which will put you into trouble later... (update-ability, etc.) – patroqueeet May 24 '16 at 12:57
  • @patroqueeet Hmm, you're actually quite correct. If you find a solution feel free to add it ;) – Bono May 24 '16 at 13:12
  • the template is there: https://github.com/klen/django_markdown/blob/master/django_markdown/templates/django_markdown/editor_init.html - hence, if your setup is correct, you would probably talk to the package maintainer. the package (django_markdown) is at least running fine for me. I can share my conf if that would help you... – patroqueeet Jun 09 '16 at 07:53