Я пытаюсь динамически генерировать свой url_for, как это, и он не работает ...:
search. html
<a href="{{ url_for('{{ country }}') }}"
Здесь я запрашиваю свои данные для моего ссылка из моей базы данных.
rout.py
from app import app, db
from app.models import
@app.route('/search')
def search():
country = Country.query.get(3)
return render_template('search.html', country=country.country)
#this is one of the final page where the link in the search results lead
#I will have /portugal, /france, etc...
@app.route('/germany')
def germany():
return render_template('germany.html')
, и это фрагмент информации в моей базе данных:
models.py
from app import db
class Country(db.Model):
id = db.Column(db.Integer, primary_key=True)
country = db.Column(db.String(120), index=True, unique=True)
html_page = db.Column(db.String(255), index=True, unique=True)
def __repr__(self):
return '<Country {}>'.format(self.country)
Нужно ли мне даже сохранять URL-адрес, поскольку он совпадает с названием страны aka @ germany