0

我的一些自定义模型的信号在保存例如 Auth 用户时以某种方式被触发

这是在我的signals.py中:

product_document_model = 'document_manager.models.ProductDocument'
app_label, _, class_name  = product_document_model.split('.')
product_document_model = get_model(app_label, class_name)

@receiver(post_save, sender=product_document_model)
def save_products(sender, instance, signal, created, **kwargs):
   ...

我的模型:

import os.path
from django.db import models
class Document(models.Model):
    _file = models.FileField(upload_to="documents/%Y/%m/%d")
    timestamp = models.DateTimeField(auto_now=True)

    def file_name(self):
        return os.path.basename(self._file.name)

class ProductDocument(models.Model):
    _file = models.FileField(upload_to="documents/products/%Y/%m/%d")
    timestamp = models.DateTimeField(auto_now=True)

    def file_name(self):
        return os.path.basename(self._file.name)

为什么 Auth 用户会触发这个?

4

0 回答 0