summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorkoresi <k.alv@protonmail.com>2024-11-30 00:45:06 +0100
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-04-27 16:12:47 +0200
commit231eb7acc312096e631b8ca11abb4863ce8ea6df (patch)
treeb5f90017fcbead36bf3ec0f860f9cb81f27ee159 /docs/ref
parentc08764cb2e047b20728661ce8c17d0fca498b2cd (diff)
[5.2.x] Fixed #35931 -- Documented fields and methods of the FlatPage model.
Co-authored-by: Clifford Gama <53076065+cliff688@users.noreply.github.com> Backport of 0ee06c04e0256094270db3ffe8b5dafa6a8457a3 from main.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/contrib/flatpages.txt76
1 files changed, 68 insertions, 8 deletions
diff --git a/docs/ref/contrib/flatpages.txt b/docs/ref/contrib/flatpages.txt
index 8a2fda3f92..aa70260df5 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 </topics/db/models>`,
- which lives in :source:`django/contrib/flatpages/models.py`. You can access
- flatpage objects via the :doc:`Django database API </topics/db/queries>`.
-
-.. currentmodule:: django.contrib.flatpages
+Flatpages are represented by a standard
+:doc:`Django model </topics/db/models>`, :class:`.FlatPage`. You can access
+flatpage objects via the :doc:`Django database API </topics/db/queries>`.
.. 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 <django.db.models.Field.blank>`).
+ :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 <flatpages-admin>` for a
+ detailed explanation.
+
+ .. attribute:: template_name
+
+ Optional (:attr:`blank=True <django.db.models.Field.blank>`). 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 </ref/contrib/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
==================