ではdjango / django / contrib / admin / templates / admin / login.html
、フォームのアクション パスは です{{ app_path }}
。どういう意味ですか?その上、 にchange_password_form
は、アクション パスがまったくありません。フォームはどのように機能しますか?
1 に答える
5
{{ app_path }}
ビューから渡されたコンテキストに置き換えられるテンプレート変数です。この場合、ビューは次のdjango/contrib/admin/sites.py
とおりです。
@never_cache
def login(self, request, extra_context=None):
"""
Displays the login form for the given HttpRequest.
"""
from django.contrib.auth.views import login
context = {
'title': _('Log in'),
'app_path': request.get_full_path(),
REDIRECT_FIELD_NAME: request.get_full_path(),
}
context.update(extra_context or {})
defaults = {
'extra_context': context,
'current_app': self.name,
'authentication_form': self.login_form or AdminAuthenticationForm,
'template_name': self.login_template or 'admin/login.html',
}
return login(request, **defaults)
so{{ app_path }}
によって返される値に置き換えられますrequest.get_full_path()
。これは、リクエストの送信元のパスです。この場合、最初にフォームをロードした URL です。
2 番目の質問に対して、空の文字列のアクションは、ブラウザーが現在読み込んでいる URL でフォームをポイントします。
于 2013-02-12T07:41:33.290 に答える