Models

class feeds.models.Source(*args, **kwargs)

This class represents a Feed to be read.

It really should have been called Feed, but what can you do?

name

str The name of the Feed (automatically populated)

site_url

str url of the website associated with the feed (automatically populated)

feed_url

str The URL that will be fetched to read the feed

image_url

str The url of an image representing the feed (automatically populated)

description

str The site description: may be HTML, be careful (automatically populated)

last_polled

datetime The last time the Feed was fetched

due_poll

datetime When the Feed is next due to be fetched

last_result

str The result the last fetch

interval

int How often the Feed will be fetched in minutes

last_success

datetime When the Feed was last read successfully

last_change

datetime When the Feed last changed

live

bool Is the Feed being actively fetched

json

dict Raw information about the Feed in JSON format (will not be collected unless FEEDS_SAVE_JSON is set to True in settings)

is_cloudflare

bool Is this feed being hindered bt Cloudflare?

property subscriber_count: int

int he number of subscribers this feed has

property unread_count: int

int In a single user system how many unread articles are there?

If you need more than one user, or want to arrange feeds into folders, use a Subscription

str The best user facing link to this feed.

Will be the site_url if it’s present, otherwise feed_url

property display_name: str

str The best user-facing name for this feed.

Will be the the feed’s name as described in the feed if there is one. Otherwise it will be the best_link

get_unread_posts(newest_first=True)

List[Post] In a single user system get all unread posts

If you need more than one user, or want to arrange feeds into folders, use a Subscription

Parameters:

newest_first (bool)

Return type:

list

get_paginated_posts(page, newest_first=True, posts_per_page=20)

Get a posts from the feed a page at a time

Parameters:
  • page (int) – The page to fetch.

  • oldest_first (bool) – Get the posts in reverse chronological order (default True)

  • posts_per_page (int) – The number of posts per page (default 20)

  • newest_first (bool)

Returns:

A tuple containting the page of posts and the paginator

Return type:

Tuple[List[Post], Paginator]

mark_read()

In a single user system, mark this feed as read

exception DoesNotExist
exception MultipleObjectsReturned
class feeds.models.Post(*args, **kwargs)

An entry in a feed

source

Source The source feed that this post belongs to

title

str The post title

body

str The main content of the feed in html or plain text

str Link to this post on the web

found

datetime When this post was first discovered

created

datetime The created date for this post as reported in the feed

guid

str The unique ID for this post

author

str Name of the author of this post as reported by the feed

index

int The number of this post in the feed for the purposes of tracking read/unread state

image_url

str The URL of an image that represents this post

json

dict Raw information about the Post in JSON format (will not be collected unless FEEDS_SAVE_JSON is set to True in settings)

property current_enclosures

ResultSet[Enclosure] Returns all the current enclosures for this post

property old_enclosures

ResultSet[Enclosure] Returns all the previous enclosures for this post

Some feeds change the URL of enclosures between reads. By default old enclosures are deleted and new ones added each time the feed is polled. To keep references to old enclosures set FEEDS_KEEP_OLD_ENCLOSURES to True in settings.

save(*args, **kwargs)

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

exception DoesNotExist
exception MultipleObjectsReturned
class feeds.models.Enclosure(*args, **kwargs)

An enclosure on a post

post

Post The Post that this Enclosure belongs to

exception DoesNotExist
exception MultipleObjectsReturned
length

int Size in bytes of the the related file

href

url The url of the enclosure

type

str The type of the enclosure

medium

str The type of the enclosure. Almost certainly one of image/video/audio

description

str A description of the enclosure - e.g. Alt text on an image

is_current

bool Is this enclosure current (if we are saving old enclosures - see above).

property is_image

bool Is the enclosure an image?

property is_audio

bool Is the enclosure audio?

property is_video

bool Is the enclosure video?

class feeds.models.Subscription(*args, **kwargs)

A subscription to a Source Feed by a User

Subscriptions are also the way folder structures are set up

exception DoesNotExist
exception MultipleObjectsReturned
user

User The owner of the Subscription

source

Source The source feed of the subscription. If this is None then this is actually a folder

parent

Subscription The parent folder of the subscription. None if the subscription is at the root leve

is_river

bool Indicates if the feed/folder should be displayed in a “River of News” style

name

str The display name of the subscription - typically should be set to the name of the source where present

property unread_count: int

int The number of undread posts in teh subscription

If the subscription is acting as a folder, this will total up the unread counts of all children

get_unread_posts(oldest_first=True)

Returns all the unread posts in a subscription

get_paginated_posts(page, oldest_first=True, posts_per_page=20)

Get a posts from the feed a page at a time

Parameters:
  • page (int) – The page to fetch.

  • posts_per_page (int) – The number of posts per page (default 20)

  • oldest_first (bool)

Returns:

A tuple containting the page of posts and the paginator

Return type:

Tuple[List[Post], Paginator]

mark_read()

Marks all the posts in the subscription as read

If the subscription is acting as a folder then it will mark all children as read as well.