Created
May 16, 2012 20:46
-
-
Save readevalprint/2713810 to your computer and use it in GitHub Desktop.
EmailAddress class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Define this after UserProfile or import it if possible and 99% sure is null=False by default