From ac40b8076466afa86a0c51569764a1cab01153c6 Mon Sep 17 00:00:00 2001 From: Aleksander Vognild Burkow Date: Fri, 26 Jul 2019 15:48:38 +0000 Subject: [PATCH] Mention solution to potential PYTHONPATH pitfall. (#115) --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d3dbb40..951dad1 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,11 @@ django_settings_module = mysettings ``` where `mysettings` is a value of `DJANGO_SETTINGS_MODULE` (with or without quotes) +Do you have trouble with mypy / the django plugin not finding your settings module? Try adding the root path of your project to your PYTHONPATH environment variable. If you use pipenv you can add the following to an `.env` file in your project root which pipenv will run automatically before executing any commands.: +``` +PYTHONPATH=${PYTHONPATH}:${PWD} +``` + New implementation uses Django runtime to extract models information, so it will crash, if your installed apps `models.py` is not correct. For this same reason, you cannot use `reveal_type` inside global scope of any Python file that will be executed for `django.setup()`. In other words, if your `manage.py runserver` crashes, mypy will crash too. @@ -63,4 +68,4 @@ Otherwise, custom type will be created in mypy, named `MyUser__MyUserManager`, w We have Gitter here https://gitter.im/mypy-django/Lobby. -If you think you have more generic typing issue, please refer to https://github.com/python/mypy and their Gitter. \ No newline at end of file +If you think you have more generic typing issue, please refer to https://github.com/python/mypy and their Gitter.