[Answer]-Is it possible to ignore a system check error in Django 1.7+

1👍

I’ve found a solution to the problem for the time being. Ultimately I’d refactor the old project to use a custom user model of it’s own. But a temporary fix is using a subclass of ForeignKey to reference django.contrib.auth.User which skips the check for swapped model.

class ForeignKeySkipsSwappedCheck(models.ForeignKey):

    def check(self, **kwargs):
        from django.db.models.fields.related import RelatedField
        errors = super(RelatedField, self).check(**kwargs)
        errors.extend(self._check_related_name_is_valid())
        errors.extend(self._check_relation_model_exists())
        errors.extend(self._check_clashes())
        return errors
👤Vasil

Leave a comment