What's the model(or name) who calls shared met

2019-08-23 11:41发布

问题:

I have a catalog to save all address from any "form" in django admin (called by models.ForeignKey), with street, number, city, that's Okay - but I want to save the name of field(or class, or filename, something ) that invoked this address method, to save together address information any reference about the source asked for

class TraderClass(models.Model):
      trader_ID = models.AutoField(primary_key=True)

      caller #1
      address_enterprise = models.ForeignKey(AddressClass, on_delete=models.CASCADE, default=None, verbose_name='Address')


class EnterpriseClass(models.Model):
      enterprise_ID = models.AutoField(primary_key=True)

      caller #2
      address_project = models.ForeignKey(AddressClass, on_delete=models.CASCADE, default=None, verbose_name='Address')

The Address

class AddressClass(models.Model):
    ID = models.AutoField(primary_key=True)

    address_source = models.CharField(max_length=32,
    default=__qualname__,verbose_name='Origin')

\__qualname\__ only shows the same class "AddressClass" I need something like TraderClass/EnterpriseClass OR address_enterprise/address_project or anything I can save with the address