Opened 18 years ago
Closed 18 years ago
#2132 closed defect (duplicate)
Markup contrib module return different types for different markups
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Contrib apps | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
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.
Note:
See TracTickets
for help on using tickets.
Closing in favor of #2489.