You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `pyproject.toml`:
- 'ignore' -> 'lint.ignore'
- 'select' -> 'lint.select'
tests/roots/test-docstrings/dummy_django_app/models.py:22:7: DJ008 Model does not define `__str__` method
tests/roots/test-docstrings/dummy_django_app/models.py:26:7: DJ008 Model does not define `__str__` method
tests/roots/test-docstrings/dummy_django_app/models.py:82:7: DJ008 Model does not define `__str__` method
tests/roots/test-docstrings/dummy_django_app/models.py:86:7: DJ008 Model does not define `__str__` method
tests/roots/test-docstrings/dummy_django_app/models.py:90:7: DJ008 Model does not define `__str__` method
tests/roots/test-docstrings/dummy_django_app/models.py:119:11: DJ008 Model does not define `__str__` method
tests/roots/test-docstrings/dummy_django_app/models.py:123:7: DJ008 Model does not define `__str__` method
Found 7 errors.
Proposed Solution
Edit pyproject.toml to fix the two warnings above and add DJ to the lint.select and then add .__str__() methods to the 7 Django models.
% ruff rule DJ008
django-model-without-dunder-str (DJ008)
Derived from the flake8-django linter.
What it does
Checks that __str__ method is defined in Django models.
Why is this bad?
Django models should define __str__ method to return a string representation
of the model instance, as Django calls this method to display the object in
the Django Admin and elsewhere.
Models without __str__ method will display a non-meaningful representation
of the object in the Django Admin.
@cclauss feel free to contribute this change, but I don't think it's strictly necessary. The dummy django app is only used for testing and not contained in the package distribution shipped via PyPI.
Motivation
%
ruff --select=DJ
# https://docs.astral.sh/ruff/rules/django-model-without-dunder-strProposed Solution
Edit
pyproject.toml
to fix the two warnings above and addDJ
to thelint.select
and then add.__str__()
methods to the 7 Django models.%
ruff rule DJ008
django-model-without-dunder-str (DJ008)
Derived from the flake8-django linter.
What it does
Checks that
__str__
method is defined in Django models.Why is this bad?
Django models should define
__str__
method to return a string representationof the model instance, as Django calls this method to display the object in
the Django Admin and elsewhere.
Models without
__str__
method will display a non-meaningful representationof the object in the Django Admin.
Example
Use instead:
Alternatives
Additional Context
The text was updated successfully, but these errors were encountered: