From 0ee06c04e0256094270db3ffe8b5dafa6a8457a3 Mon Sep 17 00:00:00 2001 From: koresi Date: Sat, 30 Nov 2024 00:45:06 +0100 Subject: [PATCH] Fixed #35931 -- Documented fields and methods of the FlatPage model. Co-authored-by: Clifford Gama <53076065+cliff688@users.noreply.github.com> --- docs/ref/contrib/flatpages.txt | 76 ++++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/docs/ref/contrib/flatpages.txt b/docs/ref/contrib/flatpages.txt index 3d0aca9156..6329920de2 100644 --- a/docs/ref/contrib/flatpages.txt +++ b/docs/ref/contrib/flatpages.txt @@ -221,14 +221,9 @@ registering a custom ``ModelAdmin`` for ``FlatPage``:: Via the Python API ------------------ -.. class:: FlatPage - - Flatpages are represented by a standard - :doc:`Django model `, - which lives in :source:`django/contrib/flatpages/models.py`. You can access - flatpage objects via the :doc:`Django database API `. - -.. currentmodule:: django.contrib.flatpages +Flatpages are represented by a standard +:doc:`Django model `, :class:`.FlatPage`. You can access +flatpage objects via the :doc:`Django database API `. .. admonition:: Check for duplicate flatpage URLs. @@ -238,6 +233,71 @@ Via the Python API ``django.contrib.flatpages.forms.FlatpageForm`` and used in your own views. +.. currentmodule:: django.contrib.flatpages + +``FlatPage`` model +================== + +.. class:: models.FlatPage + +Fields +------ + +:class:`~django.contrib.flatpages.models.FlatPage` objects have the following +fields: + +.. class:: models.FlatPage + :noindex: + + .. attribute:: url + + Required. 100 characters or fewer. Indexed for faster lookups. + + .. attribute:: title + + Required. 200 characters or fewer. + + .. attribute:: content + + Optional (:attr:`blank=True `). + :class:`~django.db.models.TextField` that typically, contains the HTML + content of the page. + + .. attribute:: enable_comments + + Boolean. This field is not used by :mod:`~django.contrib.flatpages` by + default and does not appear in the admin interface. Please see + :ref:`flatpages admin interface section ` for a + detailed explanation. + + .. attribute:: template_name + + Optional (:attr:`blank=True `). 70 + characters or fewer. Specifies the template used to render the page. + Defaults to :file:`flatpages/default.html` if not provided. + + .. attribute: registration_required + + Boolean. When ``True``, restricts the page access to logged-in users + only. + + .. attribute:: sites + + Many-to-many relationship to + :class:`~django.contrib.sites.models.Site`, which determines the + :doc:`sites ` the flatpage is available on. + +Methods +------- + +.. class:: models.FlatPage + :noindex: + + .. method:: get_absolute_url() + + Returns the relative URL path of the page based on the + :attr:`~django.contrib.flatpages.models.FlatPage.url` attribute. + Flatpage templates ==================