I have a problem about markdown and django integration. After I installed markdown and change my model class to:
class Page(models.Model):
class Translation(multilingual.Translation):
title = models.CharField(verbose_name="Title", max_length=30,
help_text="Put a title (max. 30 chars) of your page -e.g. About, CEO, Contact etc...")
content_markdown = models.TextField(verbose_name="Markdown Content",
help_text="Use Markdown syntax here.")
content = models.TextField(verbose_name="Page content as HTML",
blank=True, null=True,
help_text="You don't have to touch here.")
slug = models.SlugField(verbose_name="Slug",
help_text="Put here the name of your page without space -e.g. research-development")
class Meta:
verbose_name_plural = "Pages"
ordering = ['id']
def __unicode__(self):
return self.title
def save(self):
import markdown
self.content = markdown.markdown(self.content_markdown)
super(Page, self).save()
def get_absolute_url(self):
# return "/%s/%s" % (self.menu.slug, self.slug)
return "/%s" % self.slug
I got these traceback:
Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
92. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/options.py" in wrapper
226. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in inner
186. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/db/transaction.py" in _commit_on_success
240. res = func(*args, **kw)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/options.py" in add_view
734. self.save_model(request, new_object, form, change=False)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/options.py" in save_model
557. obj.save()
File "/media/DATA/Programming/pyworkspace/djangoprojects/youngjin/../youngjin/archive/models.py" in save
37. self.content = markdown.markdown(self.content_markdown)
File "/usr/local/lib/python2.6/dist-packages/Markdown-2.0.1-py2.6.egg/markdown/__init__.py" in markdown
587. return md.convert(text)
File "/usr/local/lib/python2.6/dist-packages/Markdown-2.0.1-py2.6.egg/markdown/__init__.py" in convert
370. if not source.strip():
Exception Type: AttributeError at /admin/archive/page/add/
Exception Value: 'NoneType' object has no attribute 'strip'
I cannot really figure out what is the problem. Any idea?