From 696a581bca6c66c3f0f5f48823025749d3d336c0 Mon Sep 17 00:00:00 2001 From: Dani Alcala <112832187+clavedeluna@users.noreply.github.com> Date: Tue, 27 Feb 2024 17:43:56 -0300 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Dan D'Avella --- src/core_codemods/django_model_without_dunder_str.py | 2 +- .../docs/pixee_python_django-model-without-dunder-str.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core_codemods/django_model_without_dunder_str.py b/src/core_codemods/django_model_without_dunder_str.py index 3239d0d6d..5ce5ebc33 100644 --- a/src/core_codemods/django_model_without_dunder_str.py +++ b/src/core_codemods/django_model_without_dunder_str.py @@ -76,7 +76,7 @@ def dunder_str_method() -> cst.FunctionDef: DjangoModelWithoutDunderStr = CoreCodemod( metadata=Metadata( name="django-model-without-dunder-str", - summary="Ensure Django Model Classes Implement A `__str__` Method", + summary="Ensure Django Model Classes Implement a `__str__` Method", review_guidance=ReviewGuidance.MERGE_AFTER_REVIEW, references=[ Reference( diff --git a/src/core_codemods/docs/pixee_python_django-model-without-dunder-str.md b/src/core_codemods/docs/pixee_python_django-model-without-dunder-str.md index 4ce94f53e..61952c1e5 100644 --- a/src/core_codemods/docs/pixee_python_django-model-without-dunder-str.md +++ b/src/core_codemods/docs/pixee_python_django-model-without-dunder-str.md @@ -1,8 +1,8 @@ -If you've ever actively developed or debugged a Django application, you may have noticed Django models and their instances can sometimes be hard to read or distinguish one instance from another. Loading models in the interactive Django console or viewing them in the admin interface can be puzzling. This is because Django is trying to display your model objects as a plain strings. +If you've ever actively developed or debugged a Django application, you may have noticed that the string representations of Django models and their instances can sometimes be hard to read or to distinguish from one another. Loading models in the interactive Django console or viewing them in the admin interface can be puzzling. This is because the default string representation of Django models is fairly generic. -We've written this codemod to make your model objects human-readable. It will automatically detect all of your model's fields and display them as a nice string. +This codemod is intended to make the string representation of your model objects more human-readable. It will automatically detect all of your model's fields and display them as a descriptive string. -For example, the `Question` model from Django's popular Poll App tutorial will look like this: +For example, the default string representation of the `Question` model from Django's popular Poll App tutorial looks like this: ```diff from django.db import models @@ -16,7 +16,7 @@ class Question(models.Model): + return f"{model_name}({fields_str})" ``` -Without this change, the `Question` objects look like this in the interactive Django shell: +Without this change, the string representation of `Question` objects look like this in the interactive Django shell: ``` >>> Question.objects.all() ]>