Skip to content

Instantly share code, notes, and snippets.

@jpotts18
Created May 15, 2014 22:00
Show Gist options
  • Save jpotts18/9a3507ecbbc6c0be9ec0 to your computer and use it in GitHub Desktop.
Save jpotts18/9a3507ecbbc6c0be9ec0 to your computer and use it in GitHub Desktop.
class Team(models.Model):
"""
This model should be thought of as an Access Window, because
it is easier to understand what is actually going on.
"""
# Fields
name = models.CharField(_('Name'), max_length=100, blank=False)
address_1 = models.CharField(_('Address 1'), max_length=100, blank=False)
address_2 = models.CharField(_('Address 2'), max_length=100, blank=True)
zipcode = models.CharField(_('ZIP code'), max_length=5, blank=False)
city = models.CharField(_('City'), max_length=100, blank=False)
state = models.CharField(_('State'), max_length=2, blank=False)
logo = models.URLField(_('Company Logo'), blank=True, default='')
phone_regex = RegexValidator(regex=r'^\+?1?\d{9,15}$',
message="Phone number must be entered in the format: '+999999999'. Up to 15 digits allowed.",)
phone = models.CharField(max_length=15, validators=[phone_regex], blank=False)
# Relationships
user = models.ManyToManyField(CustomUser, related_name='teams')
def __str__(self):
return "%s - %s - %s" % (self.name, self.city, self.state)
class Meta:
app_label = 'api'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment