Django REST Framework 序列化程序:无法导入模型

Django REST Framework Serializer: Can't import model

我有一个模型,我正试图用它制作序列化程序,但是我无法将模型导入 serializers.py。当我这样做时出现此错误:

ModuleNotFoundError: 没有名为 'airquality.air_quality'

的模块

这是我要导入的模型

class Microcontrollers(models.Model):
    name = models.CharField(max_length=25)
    serial_number = models.CharField(max_length=20, blank=True, null=True)
    type = models.CharField(max_length=15, blank=True, null=True)
    software = models.CharField(max_length=20, blank=True, null=True)
    version = models.CharField(max_length=5, blank=True, null=True)
    date_installed = models.DateField(blank=True, null=True)
    date_battery_last_replaced = models.DateField(blank=True, null=True)
    source = models.CharField(max_length=10, blank=True, null=True)
    friendly_name = models.CharField(max_length=45, blank=True, null=True)
    private = models.BooleanField()

    class Meta:
        managed = True
        db_table = 'microcontrollers'
        verbose_name_plural = 'Microcontrollers'

    def __str__(self):
        return self.friendly_name

serializers.py

from rest_framework import serializers

from airquality.air_quality.models import Microcontrollers


class SourceStationsSerializer(serializers.ModelSerializer):
    def create(self, validated_data):
        pass

    def update(self, instance, validated_data):
        pass

    class Meta:
        model = Microcontrollers
        fields = ['name']

导入是 IDE 本身建议我在序列化程序中键入 model = Microcontrollers 时使用的导入

如果文件在同一目录中,则使用此模型

from .models import Microcontrollers

或者如果它是另一个目录 wana 导入该模型

from directoryname.models import Microcontrollers