G'Day,
I have a number of Django projects and a number of other Python projects as git repositories. I have pre-commit hook that runs Pylint on my code before allowing me to commit it - this hook doesn't know whether the project is a Django application or a vanilla Python project.
For all my Django projects, I have a structure like:
> my_django_project
|-- manage.py
|-- settings.py
|--> apps
   |--> my_django_app
      |-- models.py
      |-- admin.py 
Now, when I run pylint on this project, it gives me errors like:
F:  4,0: Unable to import 'my_django_app.models'
for my_django_app.admin module for example. 
How to do I configure Pylint, so that when it is going over my django projects (not vanilla python projects), it knows that the my_django_project/apps should also be in the sys.path? Normally, manage.py adds it to the sys.path. 
Thanks!
Take a look at init_hook in pylint configuration file.
init-hook=import sys; sys.path.insert(0, 'my_django_project/apps');
You will obviously need a configuration file per Django application, and run pylint as, e.g.
pylint --rcfile=pylint.conf my_django_project
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With