In django / django / contrib / admin / templates / admin / login.html, the action path of the form is {{ app_path }}. What does it mean? Besides, in change_password_form, there is no action path at all. How can the form still work?
1 Answer
{{ app_path }} is a template variable will be replaced with the context passed to it from the view. In this case the view is in 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 }} will be replaced with the value returned by request.get_full_path(), which is path where the request comes from. In this case it's just the URL from which you loaded the form in the first place.
To the second question, an action of an empty string points the form at the URL the browser currently has loaded.
1 Comment
Lim H.
ahhh it makes a lot of sense. Thank you!