Skip to content

Commit a8a8302

Browse files
committed
Update for models referenced as strings. Refs #272
1 parent d03555b commit a8a8302

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

README.rst

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Usage
4646

4747
Ensure ``pylint-django`` is installed and on your path and then execute::
4848

49-
pylint --load-plugins pylint_django [..other options..] <path_to_your_sources>
49+
DJANGO_SETTINGS_MODULE=your.app.settings pylint --load-plugins pylint_django [..other options..] <path_to_your_sources>
5050

5151

5252
Prospector
@@ -70,6 +70,9 @@ Features
7070
* Validates ``Model.__unicode__`` methods.
7171
* ``Meta`` informational classes on forms and models do not generate errors.
7272
* Flags dangerous use of the exclude attribute in ModelForm.Meta.
73+
- Uses Django's internal machinery to try and resolve models referenced as
74+
strings in ForeignKey fields. That relies on ``django.setup()`` which needs
75+
the appropriate project settings defined!
7376

7477

7578
Additional plugins
@@ -92,23 +95,6 @@ This plugin is disabled by default! To enable it::
9295
pylint --load-plugins pylint_django --load-plugins pylint_django.checkers.migrations
9396

9497

95-
Known issues
96-
------------
97-
98-
If you reference foreign-key models by their name (as string) ``pylint-django`` may not be
99-
able to find the model and will report issues because it has no idea what the underlying
100-
type of this field is. Supported options are::
101-
102-
- ``self`` and ``Model`` - look for this class in the current module which is being examined
103-
- ``app.Model`` - try loading ``app.models`` into the AST parser and look for ``Model`` there
104-
105-
106-
If your ``models.py`` itself is not importing the foreign-key class
107-
there's probably some import problem (likely circular dependencies) preventing referencing
108-
the foreign-key class directly. In this case ``pylint-django`` can't do much about it.
109-
We always recommend referencing foreign-key models by their classes.
110-
111-
11298
Contributing
11399
------------
114100

0 commit comments

Comments
 (0)