votes up 0

Instance only

Package:
django
github stars 57383
Exception Class:
AttributeError

Raise code

class Relation(models.Model):
    pass


class InstanceOnlyDescriptor:
    def __get__(self, instance, cls=None):
        if instance is None:
            raise AttributeError('Instance only')
        return 1


class AbstractPerson(models.Model):
    # DATA fields
    data_abstract = models.CharField(max_length=10)
    fk_abstract = models.ForeignKey(Relation, models.CASCADE, related_name='fk_abstract_rel')

NO FIXES YET

Just press the button and we will add solution
to this exception as soon as possible

* As many users press the button, the faster we create a fix

Add a possible fix

Please authorize to post fix