Answer the question
In order to leave comments, you need to log in
How does Django process requests?
https://djbook.ru/rel1.9/topics/http/urls.html#how...
Volume 4 definition:
If one of the regular expressions matches the URL, Django will import and call the corresponding view, which is just a function Python (or view-class). When called, the following arguments are passed:
and there are passed:
1) The HttpRequest object.
2) If the regular expression results in named matches, they will be passed as positional arguments.
3) Named arguments are created from named matches. They can be overwritten with values from the kwargs argument passed to django.conf.urls.url().
And if I specify only one parameter in my view, then how will Django pass 2 and 3 arguments?
Example :
urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name ='index'),
]
view.py
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index(request):
return HttpResponse("Hello, world.")
вот тут я указываю что моя функция принимает только один параметр
а остальные как будет получены?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question