Home>

Developing Django apps using an IDE called Pycharm (jetbrains).

In Pycharm,

  

Duplicated code fragment (5 lines long)

You will be warned about the error

.

The corresponding code is as follows.

for question in questions:
    question.votes = 0
    question.answer_counts = Answer.objects.filter (question = question) .count ()
    question.access_counts = QuestionAccess.objects.filter (question = question) .count ()
    question.title = translate (question.title, lang)
    question.content = translate (question.content, lang)
    question.access_counts = QuestionAccess.objects.filter (question = question) .count ()

It seems that the code is duplicated, but I don't know how to fix it.
Can you tell me if you understand?