Skip to content
This repository was archived by the owner on Jul 22, 2022. It is now read-only.
This repository was archived by the owner on Jul 22, 2022. It is now read-only.

get_absolute_url uses incorrect url_for arguments. #2

@adamlwgriffiths

Description

@adamlwgriffiths

Post defines the following function

def get_absolute_url(self):
        return url_for('post', kwargs={"slug": self.slug})

This function isn't used in the tutorial, but calling it results in a BuildError exception.
The Blueprint for Post is 'posts' not 'post'.
It also doesn't define which 'function' to call, Ie 'posts.detail' or 'posts.list'.

The correct code should be

def get_absolute_url(self):
        return url_for('posts.detail', slug=self.slug)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions