Когда я запустил приведенный ниже код, Django выдает ошибку обертки, код ошибки показан ниже
Сообщение об ошибке:
AttributeError: у объекта 'method-wrapper' нет атрибута ' module '
Models.py
class PatientMasters(models.Model):
patient_id = models.AutoField(primary_key=True)
patient_n_key = models.CharField(max_length=15, blank=True, unique=True)
centre_master_short_name = models.CharField(blank=False, max_length=33)
centre_master_id = models.CharField(blank=False, max_length=15)
pid_no = models.CharField(max_length=45, blank=True, null=True)
aadhar_number = models.CharField(max_length=45, blank=True, null=True)
date_of_registration = models.BigIntegerField()
patient_name = models.CharField(max_length=45,blank=False)
gender = models.CharField(max_length=45,blank=False)
patient_category = models.CharField(max_length=45, blank=True, null=True)
age = models.IntegerField(blank=False)
class Meta:
managed = False
db_table = 'patient_masters'
@receiver(post_save, sender=PatientMasters)
def generate_pat_unique_key(sender, instance, created, **kwargs):
"""
Generate unique n_key as an combination of primary key and centre_master_id
"""
post_save.disconnect(generate_pat_unique_key, sender=PatientMasters)
instance.patient_n_key = "{}-pat-{}".format(instance.centre_master_short_name, instance.patient_id)
instance.save()
post_save.connect(generate_pat_unique_key, sender=PatientMasters)
Views.py
class PatientMastersviewset(viewsets.ModelViewSet):
queryset=models.PatientMasters.objects.all()
serializer_class=serializers1.PatientMastersserializer
lookup_field = 'patient_n_key'
tasks.PatientMastersviewset.delay()
tasks.py
@app.task
class PatientMastersviewset(viewsets.ModelViewSet):
queryset=models.PatientMasters.objects.all()
serializer_class=serializers1.PatientMastersserializer
lookup_field = 'patient_n_key'