1

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()
  • Is `signals.py` in a directory called `users`, which is at the same directory level as `apps.py`? If so, delete your functions, then imports, in `signals.py` to see which is causing the issue. – GAEfan Jul 31 '20 at 00:23

1 Answers1

2

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.

crimsonpython24
  • 2,223
  • 2
  • 11
  • 27