Exemplo n.º 1
0
class TweetHashtagBase(Model):
    _id = AutoField(primary_key=True, db_column='id')
    text = CharField(max_length=255)
    indices = CommaSeparatedIntegerField(max_length=255)

    class Meta:
        abstract = True
Exemplo n.º 2
0
class TestModelFields(Model):
    big_int = BigIntegerField()
    yesno = BooleanField()
    title = CharField(max_length=150)
    csv_data = CommaSeparatedIntegerField(max_length=255)
    when = DateField()
    when_accurate = DateTimeField()
    amount = DecimalField(max_digits=8, decimal_places=4)
    email = EmailField()
    upload = FileField(upload_to='test')
    path = FilePathField(path=d.APP_DIR, recursive=False, match=".json$")
    inaccurate = FloatField()
    img = ImageField(upload_to='test')
    ip = IPAddressField()
    better_ip = GenericIPAddressField(protocol='both')
    yesnomaybe = NullBooleanField(default=None)
    posint = PositiveIntegerField()
    small_posint = PositiveSmallIntegerField()
    slug = SlugField()
    small_int = SmallIntegerField()
    content = TextField()
    when_time = TimeField()
    web_address = URLField()
    user = ForeignKey('auth.User')
    groups = ManyToManyField('auth.Group')
    one_to_one = OneToOneField('auth.Permission')

    class Meta:
        verbose_name = 'test model fields'
        verbose_name_plural = 'test model fields'
Exemplo n.º 3
0
class TweetURLBase(Model):
    _id = AutoField(primary_key=True, db_column='id')
    expanded_url = URLField()
    display_url = URLField()
    url = URLField()
    indices = CommaSeparatedIntegerField(max_length=255)

    class Meta:
        abstract = True
Exemplo n.º 4
0
class TweetMentionBase(Model):
    _id = AutoField(primary_key=True, db_column='id')
    name = CharField(max_length=255)
    screen_name = CharField(max_length=15)
    id = PositiveIntegerField(db_column='user_id')
    indices = CommaSeparatedIntegerField(max_length=255)

    class Meta:
        abstract = True
Exemplo n.º 5
0
class TweetMediaBase(Model):
    _id = AutoField(primary_key=True, db_column='id')
    expanded_url = URLField()
    indices = CommaSeparatedIntegerField(max_length=255)
    url = URLField()
    media_url = URLField()
    media_url_https = URLField()
    id = BigIntegerField(db_column='media_id')
    display_url = URLField()

    class Meta:
        abstract = True
Exemplo n.º 6
0
class SearchResult(Model):
    search = ForeignKey(Search)
    sequence = CommaSeparatedIntegerField(verbose_name='Sequence Number(s)',
                                          max_length=200)
    seq = IntegerField(verbose_name='Best Sequence Number')
    keyword = ManyToManyField(Keyword, null=True, blank=True)
    site = ForeignKey(SiteData)

    def __unicode__(self):
        return u'%s (%s)' % (self.site, self.search.date)

    class Meta:
        ordering = ["site", "search"]
        verbose_name = "Search Result"
        unique_together = ["search", "site"]
Exemplo n.º 7
0
class ComplicatedTestModel(Model):
    char_field = CharField(max_length=32)
    bigint_field = BigIntegerField()
    boolean_field = BooleanField()
    commaseparatedinteger_field = CommaSeparatedIntegerField(max_length=32)
    date_field = DateField()
    datetime_field = DateTimeField()
    decimal_field = DecimalField(decimal_places=2, max_digits=20)
    email_field = EmailField()
    file_field = FileField()
    filepath_field = FilePathField(path="/home")
    float_field = FloatField()
    image_field = ImageField()
    integer_field = IntegerField()
    ipaddress_field = IPAddressField()
    nullboolean_field = NullBooleanField()
    positiveinteger_field = PositiveIntegerField()
    positivesmallinteger_field = PositiveSmallIntegerField()
    slug_field = SlugField()
    smallinteger_field = SmallIntegerField()
    text_field = TextField()
    url_field = URLField()

    def auto_populate(self):
        self.char_field = 'foo'
        self.bigint_field = 2379238742398
        self.boolean_field = True
        self.commaseparatedinteger_field = '1, 2, 3, 4'
        self.date_field = datetime.datetime(2014, 1, 1)
        self.datetime_field = datetime.datetime(2014, 1, 1)
        self.decimal_field = 3.14
        self.email_field = '*****@*****.**'
        self.file_field = 'test.txt'
        self.filepath_field = 'test.txt'
        self.float_field = 3.14
        self.image_field = 'test.png'
        self.integer_field = 1024
        self.ipaddress_field = '8.8.8.8'
        self.nullboolean_field = None
        self.positiveinteger_field = 1024
        self.positivesmallinteger_field = 1024
        self.slug_field = 'eat-slugs-all-day-long'
        self.smallinteger_field = 3
        self.text_field = 'foo bar var\nvar bar foo'
        self.url_field = 'http://example.com'