Example #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'
Example #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'
Example #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')
Example #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"]
Example #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']
Example #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"]
Example #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')
Example #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)
Example #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")
Example #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']
Example #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)
Example #12
0
 def test_now_correcly_valuates(self):
     self.assertTrue(models.CharField(max_length=45))
Example #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)
Example #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 "_"')
Example #15
0
class Appointment(models.Model):
    name = models.CharField(max_length=50)
    date = models.DateField()
    time = models.TimeField(null=True)
    uuid = models.Uuid4Field()
Example #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'))
Example #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')
Example #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")
Example #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 "__"')
Example #20
0
 def test_now_correcly_valuates(self):
     # correctly valuates if max_length correctly defined
     self.assertTrue(models.CharField(max_length=45))
Example #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')
Example #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)
Example #23
0
class Appointment(models.Model):
    name = models.CharField(max_length=50)
    date = models.DateField()
Example #24
0
class Publisher(models.Model):
    name = models.CharField(max_length=50)
    json = models.JsonField(max_length=50, null=True)
Example #25
0
class Organization(models.Model):
    name = models.CharField(max_length=50)
    active = models.BooleanField(default=False)
Example #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")
Example #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 "_"')
Example #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')