Skip to content

Instantly share code, notes, and snippets.

@readevalprint
Created May 16, 2012 20:46
Show Gist options
  • Save readevalprint/2713810 to your computer and use it in GitHub Desktop.
Save readevalprint/2713810 to your computer and use it in GitHub Desktop.
EmailAddress class
class EmailAddress(models.Model):
email = models.EmailField(db_index=True, max_length=254, unique=True)
user = models.ForeignKey('UserProfile', null=False)
class Meta:
db_table = 'emails'
@classmethod
def search(cls, query):
if query:
q = dict('user', query)
s = S(cls).query(or_=q)
return s
def __unicode__(self):
"""Return the Email Address or return blank"""
return getattr(self, 'email', u'')
@readevalprint
Copy link
Author

Define this after UserProfile or import it if possible and 99% sure is null=False by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment