I am wanting to include dynamic variables inside of an if statement.
{% elif request.path == "/order/**{{city}}**" %}
I have a database I can refer to, to get the city names I need out depending on the url but am having a hard time sending that info in through this if statement. (Everything works dynamically up until this point)
Solutions?
CodePudding user response:
Backtrack a bit and just make the condition in the views.py
then pass a boolean
in the context
which saves you the trouble of this complicated notation which contains far too many special symbols to be worth the headache
CodePudding user response:
In the views.py
city = City.objects.get(city_slug=city_slug)
my_city = "https://www.wesbsite.com/order/{}".format(city)
was my solution to including dynamic variables in the url
found at How to add variable to URL?
I overcomplicated it but Blye pointed in the right direction, telling me to do so in the views.py as opposed to directly in the html file.