Package: django-betterFlatPages
django-betterFlatPagesThis django app is a drop in replacement for django.contrib.flatpages. The main new features that django-betterFlatPages offers as of now is the optional django-rest-framework views and a spot to add metadata. Any contribution is welcome just make a pull request, and I will try to add your feature in the next version as soon as possible.Installationprerequisitessites framework (django.contrib.sites) - make sure you have the site id setdjango-rest-framework (not required unless you want to use betterFlatPages rest api)runpip install django-betterFlatPagesAdd 'betterFlatPages' to your INSTALLED_APPS setting.Add urls (only add the urls file that you plan on using)rest api urlsurlpatterns = [
path('api/pages/', include('betterFlatPages.DRF_urls')),
]normal urls fileurlpatterns = [
path('pages/', include('betterFlatPages.urls')),
]Run the commandmanage.py migrate.using the rest apito use the rest api django-rest-framework must be installedto get the page in the rest api add the url at the end ofapi/pages/if the flatPage url is/policy/then it would be `/api/pages/policy/'the response would look something like{
    "url": "/policy/",
    "title": "privacy policy",
    "content": "this is the privacy policy",
    "enable_comments": false,
    "meta": "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"
}using custom templatesBy default, flatpages are rendered via the templatebetterFlatPages/default.html, but you can override that for a particular flatpage: in the admin, a collapsed fieldset titled “Advanced options” (clicking will expand it) contains a field for specifying a template name. If you’re creating a flat page via the Python API you can set the template name as the field template_name on the FlatPage object. (as per the django documentation)Flatpage templates are passed a single context variable, flatpage, which is the flatpage object.here is the currentdefault.html{% extends 'betterFlatPages/base.html' %}
{% block head_title %}{{ flatpage.title }}{% endblock %}

{% block extra_head %}{{ flatpage.meta | safe}}{% endblock %}

{% block content %}
<div class="bg-white p-5 rounded">
    <h1 class="text-center">{{ flatpage.title }}</h1>
    {{ flatpage.content | safe }}
</div>
{% endblock %}using metatagsyou can add meta-tags in the admin in “Advanced options" dropdownadd the meta options with the full tag just like it would be in html<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="product" content="cool product">
<meta name="etc" content="etc...">to render the tags on your template page add<head>
    ...
    {{ flatpage.meta | safe}}
    ...
</head>extending and overriding the templatevisit:https://docs.djangoproject.com/en/4.0/howto/overriding-templates/still left to docreate a management command to copy all the django.contrib.flatpages pages to better flat pages (and possibly the reverse)amazing documentation100% testing coveragecreate a replacement middleware similar to django.contrib.flatpages.middleware.FlatpageFallbackMiddlewareadd any new features django.contrib.flatpages is lackingadd all the features that django.contrib.flatpages hastemplate tagsintegration with django sitemapsuse marksafe before rendering template so user doesn't have to use the | safe filter