我是第一次嘗試這個,我在導入信號時出錯來自 apps.pyfrom django.apps import AppConfigclass ChitchatConfig(AppConfig): name = 'chitchat' def ready(self): import users.signals來自 signals.pyfrom django.db.models.signals import post_savefrom django.contrib.auth.models import Userfrom django.dispatch import receiverfrom .models import user_Profile@receiver(post_save,sender=User)def create_profile(sender,instance,created,**kwargs): if created: user_Profile(user=instance)@receiver(post_save,sender=User)def save_profile(sender,instance,**kwargs): instance.user_Profile.save()
1 回答

白衣染霜花
TA貢獻1796條經驗 獲得超10個贊
Django 有自己的導入語句,眾所周知,專為標準 python 代碼設計的 pylint 無法正確解釋某些導入語句,并可能引發錯誤。
以下是您應如何解決此問題:
安裝這個插件:
pip install pylint-django
pylintrc
在項目的最外層創建一個文件。添加--load-plugins pylint_django
到這個文件。保存文件并重新加載您的工作區。
添加回答
舉報
0/150
提交
取消