Версия python: 3.10.2
OC: Win 10 Pro
Привет!
Изучаю Django по оф документации. Встретил такой код:
Python:
def test_past_question(self):
"""
Questions with a pub_date in the past are displayed on the
index page.
"""
question = create_question(question_text="Past question.", days=-30)
response = self.client.get(reverse('polls:index'))
self.assertQuerysetEqual(
response.context['latest_question_list'],
[question],
)
Функция create_question():
Python:
def create_question(question_text, days):
"""
Create a question with the given `question_text` and published the
given number of `days` offset to now (negative for questions published
in the past, positive for questions that have yet to be published).
"""
time = timezone.now() + datetime.timedelta(days=days)
return Question.objects.create(question_text=question_text, pub_date=time)
Выше соответственно были сделаны эти импорты:
Python:
import datetime
from django.test import TestCase
from django.utils import timezone
from django.urls import reverse
from .models import Question
В чем вопрос: в функции test_past_question создается объект функции create_question
Python:
question = create_question(question_text="Past question.", days=-30)
P. S. Надеюсь понятно изложил))