Skip to content

Instantly share code, notes, and snippets.

@liushooter
Forked from gregmuellegger/fields.py
Created September 1, 2016 07:05
Show Gist options
  • Save liushooter/feb89ac2f30b12b65441803ed117a4d6 to your computer and use it in GitHub Desktop.
Save liushooter/feb89ac2f30b12b65441803ed117a4d6 to your computer and use it in GitHub Desktop.
A django.db.models.fields.EmailField that forces lower case letters.
'''
Taken from: https://code.djangoproject.com/ticket/17561#comment:7
'''
from django.db import models
class EmailField(models.EmailField):
def get_prep_value(self, value):
value = super(EmailField, self).get_prep_value(value)
if value is not None:
value = value.lower()
return value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment