Пример #1
0
class C(models.Model):
    "all with akas"
    c001 = models.AutoField(primary_key=True, aka='xxx')
    c002 = models.BooleanField(aka='xxx')
    c003 = models.CharField(maxlength='256', aka='xxx')
    c004 = models.CommaSeparatedIntegerField(maxlength='256', aka='xxx')
    c005 = models.DateField(aka='xxx')
    c006 = models.DateTimeField(aka='xxx')
    if deseb.version == 'trunk':
        c007 = models.DecimalField(decimal_places=5, max_digits=10,
                                   aka='xxx')  # not in v0.96
    c008 = models.EmailField(aka='xxx')
    c010 = models.FileField(upload_to='/tmp', aka='xxx')
    c011 = models.FilePathField(aka='xxx')
    if deseb.version == '0.96':
        c012 = models.FloatField(aka='xxx', decimal_places=5,
                                 max_digits=10)  # for v0.96
    else:
        c012 = models.FloatField(aka='xxx')
    c013 = models.IPAddressField(aka='xxx')
    c014 = models.ImageField(upload_to='/tmp', aka='xxx')
    c015 = models.IntegerField(aka='xxx')
    c016 = models.NullBooleanField(aka='xxx')
    #   c017 = models.OrderingField(maxlength='256')
    c018 = models.PhoneNumberField(aka='xxx')
    c019 = models.PositiveIntegerField(aka='xxx')
    c020 = models.PositiveSmallIntegerField(aka='xxx')
    c021 = models.SlugField(aka='xxx')
    c022 = models.SmallIntegerField(aka='xxx')
    c023 = models.TextField(aka='xxx')
    c024 = models.TimeField(aka='xxx')
    c025 = models.URLField(aka='xxx')
    c026 = models.USStateField(aka='xxx')
    c027 = models.XMLField(aka='xxx')
Пример #2
0
class Profile(models.Model):
	first_name = models.CharField(max_length=100)
	last_name = models.CharField(max_length=100)
	full_name = models.CharField(max_length=200, blank=True, editable=False)
	purl_name = models.CharField(max_length=200, blank=True)
	address1 = models.CharField(max_length=250)
	address2 = models.CharField(max_length=250, blank=True)
	city = models.CharField(max_length=100)
	state = models.USStateField()
	zipcode = models.CharField(max_length=10)
	phone = models.PhoneNumberField()
	email = models.EmailField()
	purl = models.CharField(max_length=250, blank=True)
	qpath = models.CharField(max_length=1, blank=True)
	visited = models.BooleanField()
	date_created = models.DateTimeField(default=datetime.datetime.now)
	date_visited = models.DateTimeField(null=True)
	
	def __unicode__(self):
		return u'%s %s' % (self.first_name, self.last_name)
		
	def save(self):
		self.full_name = u'%s %s' % (self.first_name, self.last_name)
		stripped_fn = ""
		for f in self.first_name:
			if f in string.punctuation:
				f = ""
			stripped_fn += f
		stripped_ln = ""
		for l in self.last_name:
			if l in string.punctuation:
				l = ""
			stripped_ln += l
		pn = u'%s%s' % (stripped_fn, stripped_ln)
		self.purl_name = pn.lower()
		super(Profile, self).save()
class USStateData(models.Model):
    data = models.USStateField(null=True)
class USStatePKData(models.Model):
    data = models.USStateField(primary_key=True)