Django

Code

Ticket #2132 (closed: duplicate)

Opened 3 years ago

Last modified 2 years ago

Markup contrib module return different types for different markups

Reported by: David Larlet <larlet@gmail.com> Assigned to: adrian
Milestone: Component: Contrib apps
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

I want to use from django.contrib.markup.templatetags.markup import * and after:

MARKUP_CHOICES = (
    ('textile', 'Textile'),
    ('markdown', 'Markdown'),
    ('restructuredtext', 'ReST'),
)

def save(self):
    markup_func = globals()[self.markup]
    self.content_html = markup_func(self.content)
    super(Post, self).save() # Call the "real" save() method.

It works well for textile and markdown but there is an issue with restructuredtext because it returns unicode and not string so I have to do:

    self.content_html = str(markup_func(self.content))

This not really a critical bug but it's annoying because markup functions didn't return the same type... the patch is really easy: in /django/contrib/markup/templatetags/markup.py, replace :

return parts["fragment"]

by:

return str(parts["fragment"])

I don't know if it's a problem for filters.

Attachments

Change History

08/05/06 18:41:33 changed by adrian

  • status changed from new to closed.
  • resolution set to duplicate.

Closing in favor of #2489.


Add/Change #2132 (Markup contrib module return different types for different markups)




Change Properties
Action