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
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.
Good First Issue
%
pipx install ruff
%
ruff --select=DJ --show-source .
%
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:
%
ruff rule DJ012
Derived from the flake8-django linter.
What it does
Checks for the order of Model's inner classes, methods, and fields as per
the [Django Style Guide].
Why is this bad?
The [Django Style Guide] specifies that the order of Model inner classes,
attributes and methods should be as follows:
class Meta
def __str__()
def save()
def get_absolute_url()
Examples
Use instead:
The text was updated successfully, but these errors were encountered: