Morning all
So I have a Django form which work and submits the form data to my third party CRM as expected.
However, this form allows browsers to send feedback about the page with which the form is placed on.
Because of this, I have a hidden field (HiddenInput(...)
) which passes the URL of the current page in the value
attribute so we know which page the user is referring to. The URL is then to be seen on our end as part of the message body.
This is how I have the value
widget set up.
File name: legal.forms.py
url = forms.CharField(widget=forms.HiddenInput(attrs={'value' : '{{urll}}'}))
This is the equivalent of:
<input type = "hidden" value="<insert value>"..../>
the url
context variable is attained by the following function:
Filename ‘legal.context_processors.py’
def legal__url_path (request):
url = request.get_host() + request.path
return {'url':url}
This function has been declared in the list of context processors in the settings.py
in the following fashion:
'OPTIONS': {
'context_processors': [
.....
.....
.....
'legal.context_processors.legal__url_path',
.....
.....
.....
],
I have read the official documentation which can be found hereThe Forms API & I have to say, it’s as clear as mud.
I don’t understand why the following correctly passes the url
in the ‘value’ attribute, as follows:
‘’
With the result being:
However, doing it this way:
`…widget=forms.HiddenInput(attrs={‘value’ : ‘{{urll}}’})…’
returns the literal string, like this?
To summarise
The in the image below, the top input
is constructed via Django, the bottom is achieved via the standard HTML methodology:
What am I missing here exactly?
Thank you.