code: def attachment_upload(instance, filename):
      
      return 'attachments/{app}_{model}/{pk}/{filename}'.format(
          app=instance.content_object._meta.app_label,
          model=instance.content_object._meta.object_name.lower(),
          pk=instance.content_object.pk,
          filename=filename,
      )
docs: Stores the attachment in a "per module/appname/primary key" folder