Abhishek Sharma
Abhishek Sharma

Reputation: 71

Unable to import 'users.signals'pylint(import-error)

I am trying this for the first time and i got error in importing signals

from apps.py

from django.apps import AppConfig


class ChitchatConfig(AppConfig):
   name = 'chitchat'

   def ready(self):
       import users.signals

from signals.py


from django.db.models.signals import post_save
from django.contrib.auth.models import User
from django.dispatch import receiver
from .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()

Upvotes: 1

Views: 820

Answers (1)

crimsonpython24
crimsonpython24

Reputation: 2383

Django has its own import statements, and it's known that pylint -- which is designed for standard python code -- can't interpret some import statements properly and might raise errors.

Here's how you should fix this:

  1. Install this plugin: pip install pylint-django
  2. Create a pylintrc file on the outermost layer of your project. Add --load-plugins pylint_django to this file. Save the file and reload your workspace.

Reference and package documentation.

Upvotes: 2

Related Questions