Ticket #8320: models.py

File models.py, 1.0 KB (added by holdenweb, 16 years ago)

accounts/models.py

Line 
1from django.db import models
2from django.contrib.auth.models import User
3
4class UserType(models.Model):
5 ustid = models.IntegerField(primary_key=True)
6 usttype = models.CharField("User Type", max_length=15)
7 def __unicode__(self):
8 return self.usttype
9
10class UserProfile(models.Model):
11 user = models.ForeignKey(User, unique=True)
12 upraddr1 = models.CharField("Address line 1", max_length=50, blank=True)
13 upraddr2 = models.CharField("Address line 2",max_length=50, blank=True)
14 uprcity = models.CharField("City", max_length=30, blank=True)
15 uprstate = models.CharField("State or Province", max_length=20, blank=True)
16 uprpostcode = models.CharField("Postal Code", max_length=12, blank=True)
17 uprustid = models.ForeignKey(UserType, verbose_name="User Type", blank=True)
18 class Meta:
19 db_table = 'UserProfile'
20 def __unicode__(self):
21 return "Profile for "+str(self.user)
22 if self.user:
23 return "%s Profile" % (self.user)
24 else:
25 return "WTF?"
26
Back to Top