Dear Django group,
with Django 1.10, I used a model check like this:
class Status(models.Model):
id = models.AutoField(primary_key=True)
MAX_ID = 38
text = models.CharField(max_length=20, blank=True)
@classmethod
def check(cls, **kwargs):
errors = super(Status, cls).check(**kwargs)
maxID = cls.objects.aggregate(Max('id'))['id__max']
# The app sometimes computes histograms,
# so make sure that the Status.id values are as expected.
if cls.MAX_ID != maxID:
errors.append(checks.Warning(...))
return errors
This used to work well, considering that up to Django 1.10, this and other
checks weren't run along with `manage.py test`.
Now that Django 1.11 runs checks also with tests, the above check obviously
fails, because at the time the checks are run, the test database is still empty,
yielding `maxID = None`.
Declaring the above check as “at deployment only” seems to be a good resolution,
but is it possible to do that with a model (base-class based) check?
Best regards,
Carsten
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/03fdc69d-0ac8-b266-5533-d00301f9fdce%40cafu.de.
For more options, visit https://groups.google.com/d/optout.