mauflix/source/main/feeds.py

25 lines
645 B
Python
Raw Normal View History

2020-12-05 19:38:14 -06:00
#!/usr/bin/env python3
from django.contrib.syndication.views import Feed
from django.urls import reverse
from .models import Movie
class LatestMoviesFeed(Feed):
2022-11-17 17:51:43 -06:00
title = "Lo ultimo en MauFlix"
link = ""
description = "Ultimas diez películas disponibles en MauFlix"
2020-12-05 19:38:14 -06:00
def items(self):
2022-11-17 17:51:43 -06:00
return Movie.objects.order_by("-id")[:10]
2020-12-05 19:38:14 -06:00
def item_title(self, item):
return item.name
def item_description(self, item):
message = f"{item.name}, Dirigida por: {item.directors.all()[0]}, Año: {item.year}"
return message
def item_link(self, item):
2023-02-14 22:29:08 -06:00
return reverse("movie", args=[item.pk])