亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法導入 'users.signals'pylint(導入錯誤)

無法導入 'users.signals'pylint(導入錯誤)

繁花如伊 2023-04-18 17:39:00
我是第一次嘗試這個,我在導入信號時出錯來自 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 無法正確解釋某些導入語句,并可能引發錯誤。

以下是您應如何解決此問題:

  1. 安裝這個插件:pip install pylint-django

  2. pylintrc在項目的最外層創建一個文件。添加--load-plugins pylint_django到這個文件。保存文件并重新加載您的工作區。

查看完整回答
反對 回復 2023-04-18
  • 1 回答
  • 0 關注
  • 111 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號