That's a helper function to get the Question instances you need for
testing.  It's a way to query for those questions without repeating the
same code over and over in tests.

-Jorge

On Wed, Nov 11, 2020 at 5:56 AM Carlos Henrique <
carloshenrique...@poli.ufrj.br> wrote:

> I'm following this
> <https://docs.djangoproject.com/en/3.1/intro/tutorial05/#testing-our-new-view>
> Django tutorial. So far I haven't had an issue so far, but now I'm not
> really sure if I understood it correctly. We created a shortcut function to
> create questions, but I thought that it was meant to be user-side and when
> I use 'runserver', on the website there's no such option, only the
> previously created question. This is the code for the function:
> 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)
>
> Did I get it wrong? This function is only admin-sided? It's on
> 'polls/test.py' and it's outside every class.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f4dfe964-3417-4605-af26-d99a0d8fa4b5n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f4dfe964-3417-4605-af26-d99a0d8fa4b5n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANfN%3DK_56zjpn9yO-BvT1ec9KOY%2BOSnnRyJL%2B5E49DHuZ8_fcg%40mail.gmail.com.

Reply via email to