[Answer]-Django flatpages PAGE NOT FOUND No FlatPage matches the given query

1đź‘Ť

You have not created the default.html file. Flatpages look for a template named default.html. Here they insert their content. As you have not provided that file so flatpages raise the complaint for template does not exist.

To solve your problem follow these steps.

  1. Create a directory for templates in your project. Name it
    “templates”.
  2. In “templates” directory create a directory named
    “flatpages”.
  3. In “flatpages” directory create an html file named
    “default.html”.

Graphically it would look something like this:

enter image description here

  1. Now in default.html enter the following
<!DOCTYPE html>
<html>

<head>
  <title>{{ flatpage.title }}</title>
</head>

<body>
  <h1>{{ flatpage.title }}</h1>
  {{ flatpage.content }}
</body>

</html>
  1. Now in your settings file change the value of “TEMPLATE_DIRS” to point to this “templates” directory. It will look something like this:
TEMPLATE_DIRS = (
    "/home/wasim/so/sopro/templates",
    # Above insert your path
)

Replace the above path with your path for templates directory. Now run the server and it will work.

👤zkk

Leave a comment