0

My current project looks like this:

├── __init__.py
├── pages
├── settings.py
├── static
├── templates
│   ├── article.html
│   ├── base.html
│   ├── index.html
│   └── posts.html
├── view
│   ├── article.py
│   ├── home.py
│   ├── index.py
│   └── postwall.py

I breaked views.py(no longer in the project) into files and those files cannot generate url dynamically anymore. What i had in article.py is:

from flask import Blueprint, render_template
from app import articles
article = Blueprint('article',__name__)

@article.route('/article/<path:path>/')
def page(path):
    article = articles.get_or_404(path)
    return render_template('article.html',page=article)

Meanwhile, posts.html which offers the link button to articles doesn't work anymore:

<a href="{{ url_for('page', path=page.path) }}">More -></a>

What is the problem?Did I miss something in the blueprint file?

1 Answer 1

2

solved. change

<a href="{{ url_for('page', path=page.path) }}">More -></a>

to

<a href="{{ url_for('article.page', path=page.path) }}">More -></a>

forgot to add blueprint name

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.