In my application, I will ask user to input some text with variable and store it into database. like this...
Url
id | url |
---+-----------------------------------+
1 | http://example.com/?aaa={{para1}} |
2 | http://example.com/?aaa={{para2}} |
3 | http://example.com/?aaa={{para2}} |
4 | http://example.com/?aaa={{para1}} |
And there is a table with the actual value of those parameter.
Parameter
id | para |
---+-----------+
1 | 932580234 |
2 | 865234932 |
I want to render a html and replace the {{para1}} or {{para2}} on it.
views.py
def userpage(request):
url_obj = Url.objects.filter(id=..not_important...)[0]
url = url_obj.url
para1_obj = Parameter.objects.filter(..not_important..)[0]
para1 = para1_obj.para
para2_obj = Parameter.objects.filter(..not_important..)[0]
para2 = para2_obj.para
return render(request, 'userpage.html', {'url':url, 'para1':para1, 'para2':para2})
templates/userpage.html
You URL is {{ url }}
My expectation is
You URL is http://example.com/?aaa=932580234
However, the actual html is
You URL is http://example.com/?aaa={{para1}}
How can I "pre render" the field in database before "return render...."? Or is there any other solution for this?
I'm using python 3.4 and django 2.0
Thanks!!