ok, I've done a bit more troubleshooting and it seems the problem isn't in
the models.py, it's in the edit_event function.
in there I'm defining things like this
e.summary = cleaned_data['summary']
If I encode that bit like this now
e.summary = cleaned_data['summary'].encode('utf-8')
the problem shifts back to the models.py file
so, back in the models.py now if I comment out the encode('utf8) in the
summary and the body, it works.
But now, if you go and add a new event it will fail at that point in the
models file.
Here's a summary
http://pastie.caboo.se/77325
On 09/07/07, vanderkerkoff <[EMAIL PROTECTED]> wrote:
>
> 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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---