Ejemplo n.º 1
0
class AsyncormMigrations(models.Model):
    app_name = models.CharField(max_length=75)
    name = models.CharField(max_length=75)
    applied = models.DateTimeField(auto_now=True)

    class Meta():
        table_name = 'asyncorm_migrations'
Ejemplo n.º 2
0
class AsyncormMigrations(models.Model):
    app = models.CharField(max_length=75)
    name = models.CharField(max_length=75)
    applied = models.DateField(auto_now=True)

    class Meta():
        ordering = ('-id', )
        table_name = 'asyncorm_migrations'
Ejemplo n.º 3
0
class Author(models.Model):
    name = models.CharField(max_length=50, unique=True)
    last_name = models.CharField(max_length=50, unique=True)
    email = models.EmailField(max_length=100, null=True)
    age = models.IntegerField()

    class Meta():
        unique_together = ('name', 'last_name')
Ejemplo n.º 4
0
class Book(models.Model):
    name = models.CharField(max_length=50)
    synopsis = models.CharField(max_length=255)
    book_type = models.CharField(max_length=15,
                                 null=True,
                                 choices=BOOK_CHOICES)
    pages = models.IntegerField(null=True)
    date_created = models.DateField(auto_now=True)
    author = models.ManyToManyField(foreign_key="Author")

    class Meta:
        ordering = ["-name"]
        unique_together = ["name", "synopsis"]
Ejemplo n.º 5
0
class Book(models.Model):
    name = models.CharField(max_length=50)
    synopsis = models.CharField(max_length=255)
    book_type = models.CharField(max_length=15,
                                 null=True,
                                 choices=BOOK_CHOICES)
    pages = models.IntegerField(null=True)
    date_created = models.DateField(auto_now=True)

    class Meta():
        ordering = [
            '-name',
        ]
        unique_together = ['name', 'synopsis']
Ejemplo n.º 6
0
class Book(models.Model):
    name = models.CharField(max_length=50)
    content = models.CharField(max_length=255, choices=BOOK_CHOICES)
    date_created = models.DateField(auto_now=True)
    author = models.ForeignKey(foreign_key="Author", null=True)
    price = models.DecimalField(default=25)
    quantity = models.IntegerField(default=1)

    @staticmethod
    def its_a_2():
        return 2

    class Meta:
        table_name = "library"
        ordering = ["-id"]
        unique_together = ["name", "content"]
Ejemplo n.º 7
0
    def test_required_kwargs_not_sent(self):

        with self.assertRaises(FieldError) as exc:
            models.CharField()

        self.assertEqual(exc.exception.args[0],
                         '"CharField" field requires max_length')
Ejemplo n.º 8
0
class Skill(models.Model):
    dev = models.ForeignKey(foreign_key="Developer")
    name = models.CharField(max_length=64)
    specialization = models.ArrayField(null=True,
                                       value_type="text",
                                       db_index=True)
    notes = models.TextField(null=True)
Ejemplo n.º 9
0
class Publisher(models.Model):
    name = models.CharField(max_length=50, db_index=True)
    json = models.JsonField(max_length=50, null=True)

    mac = models.MACAdressField(null=True, dialect="unix")
    inet = models.GenericIPAddressField(null=True,
                                        protocol="both",
                                        unpack_protocol="ipv4")
Ejemplo n.º 10
0
class Book(models.Model):
    name = models.CharField(max_length=50)
    content = models.CharField(max_length=255, choices=BOOK_CHOICES)
    date_created = models.DateField(auto_now=True)
    author = models.ForeignKey(foreign_key='Author', null=True)
    price = models.DecimalField(default=25)
    quantity = models.IntegerField(default=1)

    def its_a_2(self):
        return 2

    class Meta():
        table_name = 'library'
        ordering = [
            '-id',
        ]
        unique_together = ['name', 'content']
Ejemplo n.º 11
0
class Client(models.Model):
    name = models.CharField(max_length=10)
    dev = models.ForeignKey(foreign_key='Developer')
    appoinment = models.ForeignKey(foreign_key='Appointment', null=True)
Ejemplo n.º 12
0
 def test_now_correcly_valuates(self):
     self.assertTrue(models.CharField(max_length=45))
Ejemplo n.º 13
0
class Organization(models.Model):
    name = models.CharField(max_length=50)
    active = models.BooleanField(default=False)
    date = models.DateTimeField(null=True)
    uuid = models.Uuid4Field(uuid_type="v1", db_index=True)
Ejemplo n.º 14
0
    def test_db_column_validation_wrong_start(self):
        with self.assertRaises(AsyncOrmFieldError) as exc:
            models.CharField(max_length=35, db_column="_oneone")

        self.assertEqual(exc.exception.args[0],
                         'db_column can not start with "_"')
Ejemplo n.º 15
0
class Appointment(models.Model):
    name = models.CharField(max_length=50)
    date = models.DateField()
    time = models.TimeField(null=True)
    uuid = models.Uuid4Field()
Ejemplo n.º 16
0
 def test_db_column_correctly_validates(self):
     # this is an allowed fieldname
     self.assertTrue(models.CharField(max_length=35, db_column='one_one'))
Ejemplo n.º 17
0
class Developer(models.Model):
    name = models.CharField(max_length=50, unique=True)
    age = models.IntegerField(default=25)
    org = models.ManyToManyField(foreign_key='Organization')
Ejemplo n.º 18
0
    def test_required_kwargs_wrong_value(self):
        with self.assertRaises(AsyncOrmFieldError) as exc:
            models.CharField(max_length="gt")

        self.assertEqual(exc.exception.args[0], "Wrong value for max_length")
Ejemplo n.º 19
0
    def test_db_column_validation_wrong_characters(self):
        with self.assertRaises(FieldError) as exc:
            models.CharField(max_length=35, db_column='one__one')

        self.assertEqual(exc.exception.args[0], 'db_column can not contain "__"')
Ejemplo n.º 20
0
 def test_now_correcly_valuates(self):
     # correctly valuates if max_length correctly defined
     self.assertTrue(models.CharField(max_length=45))
Ejemplo n.º 21
0
    def test_required_kwargs_wrong_value(self):
        with self.assertRaises(FieldError) as exc:
            models.CharField(max_length='gt')

        self.assertEqual(exc.exception.args[0], 'Wrong value for max_length')
Ejemplo n.º 22
0
class Reader(models.Model):
    name = models.CharField(max_length=15, default='pepito')
    size = models.CharField(choices=SIZE_CHOICES, max_length=2)
    power = models.CharField(choices=POWER_CHOICES, max_length=2, null=True)
    weight = models.IntegerField(default=weight)
Ejemplo n.º 23
0
class Appointment(models.Model):
    name = models.CharField(max_length=50)
    date = models.DateField()
Ejemplo n.º 24
0
class Publisher(models.Model):
    name = models.CharField(max_length=50)
    json = models.JsonField(max_length=50, null=True)
Ejemplo n.º 25
0
class Organization(models.Model):
    name = models.CharField(max_length=50)
    active = models.BooleanField(default=False)
Ejemplo n.º 26
0
class Author(models.Model):
    na = models.AutoField(db_column="uid")
    name = models.CharField(max_length=50, unique=True, db_index=True)
    email = models.EmailField(max_length=100, null=True, db_index=True)
    age = models.IntegerField()
    publisher = models.ManyToManyField(foreign_key="Publisher")
Ejemplo n.º 27
0
    def test_db_column_validation_wrong_ending(self):
        with self.assertRaises(FieldError) as exc:
            models.CharField(max_length=35, db_column='oneone_')

        self.assertEqual(exc.exception.args[0], 'db_column can not end with "_"')
Ejemplo n.º 28
0
class Author(models.Model):
    na = models.PkField(db_column='uid')
    name = models.CharField(max_length=50, unique=True)
    email = models.EmailField(max_length=100, null=True)
    age = models.IntegerField()
    publisher = models.ManyToManyField(foreign_key='Publisher')