class Author(models.Model): name = models.CharField(max_length=75) uuid = models.UUIDField(null=True) books = models.ArrayField(of=BookField) data = models.JSONField(default=None) created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True)
class Author(models.Model): name = models.CharField(max_length=100) sex = models.CharField(max_length=6, choices=( ('male', 'Male'), ('female', 'Female'), )) birthday = models.DateField() books = models.ArrayField(of=fields.BookField)
class Check(models.Model): id = models.UUIDField(auto_add=True, primary_key=True) unblocked = models.SmallIntegerField(default=0) created_at = models.DateTimeField(default=now) started_at = models.DateTimeField(null=True, blank=True) finished_at = models.DateTimeField(null=True, blank=True) requirements = models.ArrayField(models.TextField()) projects = models.ArrayField(models.CharField(max_length=255)) blockers = models.JSONField() public = models.BooleanField(default=True) runs = models.SmallIntegerField(default=0) project = models.ForeignKey(Project, related_name='checks', null=True, blank=True) class Meta: ordering = ('-finished_at',) def __str__(self): return str(self.id) def get_absolute_url(self): return reverse('check-detail', kwargs={'pk': str(self.pk)}) def clean(self): projects = OrderedDict() # using this since sets aren't ordered for requirement in self.requirements: url = urlparse(requirement) if url.scheme in ('http', 'https', 'file'): requirement = [sanitize_github_url(requirement, url)] try: for project in projects_from_requirements(requirement): projects[project] = None except: raise ValidationError("Couldn't check %s." % requirement) else: projects[requirement] = None self.projects = list(projects.keys()) for index, project_name in enumerate(self.projects): validators.RegexValidator(project_name_re, 'Project %s invalid' % project_name)(project_name)
def test_array_resurrection(self): """Assert that we can reconstruct an array from a South triple.""" # Create the Array field. array_field = models.ArrayField(of=('django.db.models.CharField', [], { 'max_length': 50 })) # Establish that the `of` sub-field was generated as expected. self.assertIsInstance(array_field.of, models.CharField) self.assertEqual(array_field.of.max_length, 50)
class Place(models.Model): name = models.CharField(max_length=50) books = models.ArrayField(of=models.CharField(max_length=100)) bounds = models.PolygonField()
class Hobbit(models.Model): name = models.CharField(max_length=50) favorite_foods = models.ArrayField(models.CharField(max_length=100)) created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True)
class Character(models.Model): name = models.CharField(max_length=50) items = models.ArrayField(of=fields.ItemField)