I want to call a Django view from a Django template. Is there a tag to do that ?
For example, I want to create a view which manage my login form. So basically, this view will be used just to send the Django form to the html template.
Thank you for your help.
If you are doing this only for logging users, you should read authenticating users in django which shows you how to write forms for logging in users.
If you want to send data filled in a form to a django view, simply set the
actionattribute of the form to the URL that is mapped to the view:If you are using
POST, you need to include{% csrf_token %}in your HTML form; and you should read the documention on csrf.If you want to call some functionality from the template directly, write a custom template tag, which allows you to execute arbitrary code and put the results in any template (or add them to the template context).