I have a blog site with a form for creating and updating posts. For certain content, when I copy/paste from a word document into the form for creating/editing I get a key error. It doesn't happen for text that is directly written into the form and it doesn't always happen for text that is copied from Microsoft word.
I am completely flummoxed about this. Any help would be much appreciated.
views.py:
def post_detail(request, slug=None):
instance = get_object_or_404(Post, slug=slug)
if instance.publish > timezone.now().date() or instance.draft:
if not request.user.is_staff or not request.user.is_superuser:
raise Http404
share_string = quote_plus(instance.content)
...
Error message:
Traceback:
File "/Users/cward/projects/swanson_speech_therapy2/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
149. response = self.process_exception_by_middleware(e, request)
File "/Users/cward/projects/swanson_speech_therapy2/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
147. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/cward/projects/swanson_speech_therapy2/blog/src/posts/views.py" in post_detail
49. share_string = quote_plus(instance.content)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py" in quote_plus
1308. s = quote(s, safe + ' ')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py" in quote
1303. return ''.join(map(quoter, s))
Exception Type: KeyError at /blog/test-8-9-10-11/
Exception Value: u'\u2019'