Hello everyone, using newest django trunk as of today

I've written a save overide in my models file to textile the entries,
here's the bit of that code I'm having trouble with.
def __unicode__(self):
                return self.title

        def save(self):
                if self.summary:
                        self.summary = self.summary.encode('utf8')
                        self.summary_html = textile.textile(self.summary)
                if self.body:
                        self.body = self.body.encode('utf8')
                        self.body_html = textile.textile(self.body)
                super(Event, self).save()

The edit event and add event functions in the view are almost
identical, but the problem I'm getting happens before we get to the
views file.

My web site and dbase are utf-8.

If I add a record with special characters pasted from word the first
time, it all works sweet.  Textile does it's magic, and the odd
characters do the round trip and look fine.  I can then approve them
from the admin backend, or edit them from the backend without any
trouble at all.

But if I try to edit a record with those characters in them from the
front end, it falls over on this line
self.summary = self.summary.encode('utf8')

'ascii' codec can't decode byte 0xe2 in position 5: ordinal not in
range(128)

I think, but I'm not sure, that the problem is on the first go round
I'm putting it in the web as utf8, django is grabbing it and newforms
are sending it to the save as unicode, my code is character encoding
the unicode as utf8 and that's fine.

Second go round I'm not sure what's happening or what is different
about the nature of the string.  I assumed it would be coming to me as
unicode string again and encoding it like that would work, but that
deosn't seem to be the case.

I'd appreciate any sort of help at all, suggestions or links to
reading, but I've read a fair bit about this already in my pursuit to
have django and textile and solr and odd characters from word all work
together.

Is my dream a dream and not going to be a reality?

Cheers.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to