Reputation: 109
I am trying to make include {% include %} in Django. But I face some trouble
This is the base form.html file that I trying to inherit:
<form class = 'form' method = 'POST' action = "">
{% csrf_token %}
{{form.as_p}}
<input type= "submit" value = "{{ btn_title }}" />
</form>
and this is the inherited create.html:
**{% include "form.html" with form=form btn_title = "Tweet" %}
But Actually I have this error:-
TemplateSyntaxError at /tweets/2/update
Unknown argument for 'include' tag: 'input|btn_title'.
Request Method: GET
Request URL: http://localhost:8000/tweets/2/update
Django Version: 3.0.6
Exception Type: TemplateSyntaxError
Exception Value:
Unknown argument for 'include' tag: 'input|btn_title'.
Exception Location: C:\Python\lib\site-packages\django\template\loader_tags.py in do_include, line 311
Python Executable: C:\Python\python.exe
Python Version: 3.6.8
Python Path:
['D:\\From Torrents\\Web , flask , django from torrent\\[FreeCourseSite.com] '
'Udemy - Tweetme Build a Twitter-like app step by step with Django\\src',
'C:\\Python\\python36.zip',
'C:\\Python\\DLLs',
'C:\\Python\\lib',
'C:\\Python',
'C:\\Users\\pc\\AppData\\Roaming\\Python\\Python36\\site-packages',
'C:\\Users\\pc\\AppData\\Roaming\\Python\\Python36\\site-packages\\win32',
'C:\\Users\\pc\\AppData\\Roaming\\Python\\Python36\\site-packages\\win32\\lib',
'C:\\Users\\pc\\AppData\\Roaming\\Python\\Python36\\site-packages\\Pythonwin',
'C:\\Python\\lib\\site-packages']
Server time: Mon, 21 Dec 2020 16:35:25 +0000
Upvotes: 2
Views: 882
Reputation: 2338
You can check documentation of {% include %}
Django include
{% include "form.html" with form=form btn_title="Tweet" %}
Upvotes: 0
Reputation: 477881
The formatting of the {% include … %}
template tag [Django-doc] is incorrect, it should be:
{% include "form.html" with form=form btn_title="Tweet" %}
Upvotes: 1