コード例 #1
0
class Foo(models.Model):
    foo_id = models.IntField(pk=True)
    name = models.CharField(max_length=255, index=True)
    tag = models.CharField(max_length=128)
    memo = models.TextField()

    class Meta:
        table = "foo_mapper"
コード例 #2
0
class Event(models.Model):
    id = models.IntField(pk=True)
    name = models.TextField()
    datetime = models.DatetimeField(null=True)

    class Meta:
        table = "event"

    def __str__(self):
        return self.name
コード例 #3
0
class Book(models.Model):
    id = models.IntField(pk=True)
    name = models.TextField()
    tag = models.CharField(max_length=120)

    class Meta:
        table = "book_test"

    def __str__(self):
        return self.name
コード例 #4
0
class Book(models.Model):
    id = models.IntField(pk=True)
    name = models.CharField(max_length=255, index=True)
    description = models.TextField()
    created = models.DatetimeField(auto_now_add=True)
    updated = models.DatetimeField(auto_now=True)
    data_ver = models.DataVersionField()

    class Meta:
        table = "book"
コード例 #5
0
class Foo(models.Model):
    foo_id = models.IntField(pk=True)
    name = models.CharField(max_length=255, index=True)
    tag = models.CharField(max_length=128)
    memo = models.TextField()
    content = models.JSONField()
    date = models.DateField()
    updated = models.DatetimeField(auto_now=True)
    created = models.DatetimeField(auto_now_add=True)

    class Meta:
        table = "foo_table"
        unique_together = ('name', 'date')
        indexes = ('name', 'tag')
コード例 #6
0
 class Foo(models.Model):
     foo_id = models.IntField(pk=True)
     content = models.TextField()
コード例 #7
0
 class IndexesContainWrongFieldModel(models.Model):
     id = models.AutoField()
     name = models.TextField()
     class Meta:
         indexes = ("name", "tag")
コード例 #8
0
 class IndexesListNotRightModel(models.Model):
     id = models.AutoField()
     name = models.TextField()
     class Meta:
         indexes = (1, 2, 3, 4)
コード例 #9
0
 class IndexesNotListModel(models.Model):
     id = models.AutoField()
     name = models.TextField()
     class Meta:
         indexes = 'name'
コード例 #10
0
 class ModelClassFromNotModel(NotModelClass, models.Model):
     id = models.AutoField()
     name = models.TextField()
コード例 #11
0
 class FooBar(Foo):
     bar_content = models.TextField()
コード例 #12
0
class TextFieldsModel(models.Model):
    id = models.IntField(pk=True)
    text = models.TextField()
    text_null = models.TextField(null=True)