Skip to content

Instantly share code, notes, and snippets.

@joestump
Created May 16, 2014 16:48
Show Gist options
  • Save joestump/9b76fd94378c960ed7c3 to your computer and use it in GitHub Desktop.
Save joestump/9b76fd94378c960ed7c3 to your computer and use it in GitHub Desktop.
EmailField bug in Django
class AlternateEmail(models.Model):
email = models.EmailField(unique=True)
user = models.ForeignKey(User, related_name="alternate_emails")
def __unicode__(self):
return self.email
"""
>>> from myapp.models import AlternateEmail
>>> from django.contrib.auth.models import User
>>> email = AlternateEmail()
>>> email.user = User.objects.get(pk=1)
>>> email.email = {'verified': True, 'email': 'joe@example.com'}
>>> email.save()
>>> print str(email.email)
{'verified': True, 'email': 'joe@asdf.com'}
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment