Hi Nick, As for me it is responsibility of the developer to define view function. There is only one mandatory argument 'request'. All other are based on the logic of view function and url patterns.
Say for view function that operates with entity might be natural to add 'id' as a second parameter. At the same time for view function that shows blog might be natural to get 'year' as a second parameter. And so on. I hope that helps. Regards, Constantine C. On Fri, May 12, 2017 at 5:10 PM, Nick Gilmour <[email protected]> wrote: > Thanks for the link. I understand these examples but still I would like to > see how a view function is defined. > > I also would like to see it in PyCharm. When I click on a view function in > PyCharm I only see: > > def myview_function(request) > Inferred type: (request: Any) -> HttpResponse > > I would expect to see something like this: > view_function(request, *args, **kwargs) > > I've also looked in django's source but I cannot locate it. > > On Fri, May 12, 2017 at 3:05 PM, nickeforos <[email protected]> wrote: > >> I'm following the django tutorials and documentaion as well as the django >> book. >> In >> https://docs.djangoproject.com/en/1.11/topics/http/views/ >> there is this view function: >> def current_datetime(request): >> now = datetime.datetime.now() >> html = "<html><body>It is now %s.</body></html>" % now >> return HttpResponse(html) >> >> and in: >> http://djangobook.com/django-views-dynamic-content/http://dj >> angobook.com/django-views-dynamic-content/ >> there is this view function: >> def hours_ahead(request, offset): >> try: >> offset = int(offset) >> except ValueError: >> raise Http404() >> dt = datetime.datetime.now() + datetime.timedelta(hours=offset) >> html = "In %s hour(s), it will be %s." % (offset, dt) >> return HttpResponse(html) >> >> So in the view function I can pass *request* as well as an *argument* >> from the url but how does the signature of a view function look like? >> Where can I find it in the documentation? >> Is it possible to see such signatures in PyCharm? >> >> -- >> 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 [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit https://groups.google.com/d/ms >> gid/django-users/76227b4e-5de3-4ca1-a9c6-658c2ee69529%40googlegroups.com >> <https://groups.google.com/d/msgid/django-users/76227b4e-5de3-4ca1-a9c6-658c2ee69529%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/django-users/CAH-droyZRQNwUA39G7y9fgcodtFoO_ > pn1OTgO0s1ANDsn0pRtw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAH-droyZRQNwUA39G7y9fgcodtFoO_pn1OTgO0s1ANDsn0pRtw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Sincerely yours, Constantine C -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK52boUseRLxuSX3Vm6OO14jAoA2cadRnrcNqRFJv%3D7LsMeJXg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

