ImportError for django.contrib.markup
I am trying to include a markdown app in django and added "django.contrib.markup" to INSTALLED APPS and in my model I import it as "import markdown" .. but when I go to db and try to add something I always get importer. I'm guessing the iit must be related to an app installation issue, or am I missing something?
this is how i do it in models.py:
class Entry(...)
title = models.CharField(verbose_name="Title", max_length=255)
slug = models.SlugField(verbose_name="Slug")
content_markdown = models.TextField(verbose_name="Markdown Content",
help_text="Use Markdown syntax here.")
content = models.TextField(verbose_name="Page content as HTML",
help_text="You don't have to touch here.",
blank=True, null=True)
date = models.DateTimeField(verbose_name="Date Published")
author = models.ForeignKey(User, verbose_name="Author")
def save(self):
import markdown
self.content = markdown.markdown(self.content_markdown)
super(Page, self).save()
Thank you very much in advance.
source to share
I think adding the app django.contrib.markup
to your project gives you the option {% load markup %}
in your templates (see the Django official docs ). I think you still need to install Markdown from PyPI in order to use it ( sudo easy_install Markdown
).
source to share
I have the same problem you have today. Your solution works, compile it from source, not with easy_install. But I am still not satisfied with this answer, why is easy_install not working? Do we know the Django shell server is running and not the backend server? The solution is very simple, you have to restart apache. I don't know why, but after starting the service, restart httpd (on centos), the problem is gone.
source to share