title: Emoticons from iPhone to Python/Django
body: <p>I'm trying to save comments from an iPhone app that may and nowadays most likely <em>will</em> include emoticons. No matter what I do, I can't save the emoticons to the MySQL database ... Constant Unicode errors. </p>
  
  <ul>
  <li>Python 2.6.5</li>
  <li>Django 1.2.1</li>
  <li>MySQL database (set to utf8 character set for tables and rows)</li>
  <li>Saving the data to a VARCHAR(255) field</li>
  </ul>
  
  <p>The error I keep receiving is:</p>
  
  <pre><code>Incorrect string value: '\xF0\x9F\x97\xBC \xF0...' for column 'body' at row 1
  </code></pre>
  
  <p>The string I'm passing into the database is:</p>
  
  <pre><code>test_txt = u"Emoji - \U0001f5fc \U0001f60c \U0001f47b ...".encode('utf-8')
  </code></pre>
  
  <p><strong>Update</strong>: Here's the model I'm using:</p>
  
  <pre><code>class ItemComment(db.Model):
    item = db.ForeignKey(Item)
    user = db.ForeignKey(Profile)
    body = db.CharField(max_length=255, blank=True, null=True)
  
    active = db.BooleanField(default=True)
    date_added = db.DateTimeField(auto_now_add=True)
  
    def __unicode__(self):
      return "%s" % (self.item)
  </code></pre>
  
  <p>The odd thing is, if I try and pass this to a field that I've created in MySQL and not Django models.py it works fine. But as soon as I register the field in Django models it dies. Is there another way to store these perhaps?</p>
  
  <p>Any ideas would be amazing.<br>
  I could not be more stuck on this ...</p>
  
  <p><strong>Update 2</strong>: Tracking it in Terminal using the following UPDATE statement (notice the U0001f5fc)</p>
  
  <pre><code>UPDATE 'table' SET 'body' = '', WHERE 'table'.'id' = 1 ; args=(u'\U0001f5fc')
  </code></pre>
  
  <p>Using as hardcore as I can get to pass the value:</p>
  
  <pre><code>force_unicode(smart_str(value), encoding='utf-8', strings_only=False, errors='ignore')
  </code></pre>
  
  <p>But the error still throws:</p>
  
  <pre><code>_mysql_exceptions.Warning: Incorrect string value: '\xF0\x9F\x97\xBC' for column 'body' at row 1
  </code></pre>
  
  <p>Totally lost!!!</p>
  
  <p>Cheers,</p>