On Wed, Mar 18, 2009 at 11:32 AM, Juan Hernandez <vladjani...@gmail.com>wrote:

> Hi there,
>
> This has been killing me for hours and I don't know what else to do. Is
> about the famous charset in django.
>
> I have this model:
>
> class Post(models.Model):
>     user = models.ForeignKey(User)
>     category = models.ForeignKey(Categories)
>     title = models.CharField(max_length=50)
>     post = models.CharField(max_length=10000)
>     date = models.DateTimeField(auto_now_add=True)
>
>     def __unicode__(self):
>         return u%s %s %s %s %s(self.user, self.category, self.title,
> self.post, self.date)
>
> with this information on the database:
>
> mysql> select * from blog_post;
> +----+---------+-------------+------------------+--------------------------------------------
> +---------------------+
> | id | user_id | category_id | title            |
> post                                                                  |
> date                |
> +----+---------+-------------+------------------+--------------------------------------------
> +---------------------+
> |  8 |       1 |           2 | html <i>Aqui</i> | asdfasd
> <em><strong>sdfsdfsd</strong></em> | 2009-03-18 01:27:49 |
> +----+---------+-------------+------------------+--------------------------------------------
> +---------------------+
> 8 rows in set (0.00 sec)
>
> and the post column is being rendered on django html like this:
>
> asdfasd &lt;em&gt;&lt;strong&gt;sdfsdfsd&lt;/strong&gt;&lt;/em&gt;
>
> What is going on? I have changed the CHARACTER_SET in settings.py and
> followed many things on different threats with no success at all
>
> Everything on the DB is utf8 and I also have DEFAULT_CHARSET = 'utf8' at
> settings.py
>
> How can I have django display html code from the databse without any
> problems?
>
> Thanks a lot
> Juan
>
>
> >
>
This has nothing to do with your db charset, this is Django's template
autoescape feature, you can have it render as is by doing {{ field|safe }}
that is, using the safe filter.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to