Skip to main content

News / blog plugin for the Wagtail CMS

Project description

A plugin for Wagtail that provides news / blogging functionality.

Installing

Install using pip:

pip install wagtailnews

It works with Wagtail 4.0 and upwards. For older versions of Wagtail see past releases.

Quick start

Create news models for your application that inherit from the relevant wagtailnews models:

from django.db import models

from wagtail.admin.panels import FieldPanel
from wagtail.fields import RichTextField
from wagtail.models import Page

from wagtailnews.models import NewsIndexMixin, AbstractNewsItem, AbstractNewsItemRevision
from wagtailnews.decorators import newsindex


# The decorator registers this model as a news index
@newsindex
class NewsIndex(NewsIndexMixin, Page):
    # Add extra fields here, as in a normal Wagtail Page class, if required
    newsitem_model = 'NewsItem'

    featured_news_item = models.ForeignKey(
        'NewsItem',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+',
    )

    content_panels = Page.content_panels + [
        FieldPanel('featured_news_item'), # This will set up a chooser for selecting a news item
    ]


class NewsItem(AbstractNewsItem):
    # NewsItem is a normal Django model, *not* a Wagtail Page.
    # Add any fields required for your page.
    # It already has ``date`` field, and a link to its parent ``NewsIndex`` Page
    title = models.CharField(max_length=255)
    body = RichTextField()

    panels = [
        FieldPanel('title', classname='full title'),
        FieldPanel('body', classname='full'),
    ] + AbstractNewsItem.panels

    def __str__(self):
        return self.title


class NewsItemRevision(AbstractNewsItemRevision):
    newsitem = models.ForeignKey(NewsItem, related_name='revisions', on_delete=models.CASCADE)

Old docs

The docs for Wagtail news are severely out of date, but may still be useful for reference.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtailnews-4.0.1.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

wagtailnews-4.0.1-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file wagtailnews-4.0.1.tar.gz.

File metadata

  • Download URL: wagtailnews-4.0.1.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for wagtailnews-4.0.1.tar.gz
Algorithm Hash digest
SHA256 beb68099d0c49924557e3f66f0c52f91853044c4d9dcad6e3c4d42e665ee2b2d
MD5 48050be211ac4caf81e5d30371dd793d
BLAKE2b-256 372f20849bdb57757f11478dceee1d2e5dfde92993ac90d5796bdfec0f417d01

See more details on using hashes here.

File details

Details for the file wagtailnews-4.0.1-py3-none-any.whl.

File metadata

  • Download URL: wagtailnews-4.0.1-py3-none-any.whl
  • Upload date:
  • Size: 31.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for wagtailnews-4.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a85ffa96fa0a717b79e500300894d8a0b763fcecf9222a5f3a736d71e189e8f
MD5 f154c26dd271271e1ba631eeb8117194
BLAKE2b-256 627018ae07f9d68536200c793028533a4b4a0860f6de457fbee363b8000220d8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page