D
D
dima_lenk0v2021-11-11 11:38:37
Django
dima_lenk0v, 2021-11-11 11:38:37

How to add the ability to host third-party feeds to a rss feed created in django?

Created an RSS feed in django. News is added through the admin panel and immediately automatically generated in the xml file.

feeds.py

from django.contrib.syndication.views import Feed
from django.template.defaultfilters import truncatewords
from .models import Posts
from django.urls import reverse


class LatestPostsFeed(Feed):
    title = 'Новости связанные с недвижимостью и не только'
    link = ''
    description = 'Новые публикации связанные с недвижимостью и не только'

    def items(self):
        return Posts.objects.order_by('-created_at')

    def item_title(self, item):
        return item.title

    def item_description(self, item):
        return truncatewords(item.content, 30)

    def item_link(self, item):
        return reverse('detail_post', args={item.pk})


urls.py
from django.urls import path
from .views import *
from .feeds import LatestPostsFeed


urlpatterns = [
    path('', BlogPage.as_view(), name='blog'),
    path('/<int:pk>/', BlogDetail.as_view(), name='detail_post'),
    path('/RSSfeed/', LatestPostsFeed(), name='post_feed'),
]


But I need to still be able to post third-party rss channels and articles from these channels, how can I do this, please tell me?

Maybe in the admin panel you need to add a field where the link to the rss feed will be placed? But in this case, I'm not sure that it will get into the xml file.
If the xml file was created manually, then I would simply copy the link to the rss channel and that's it, but the file is created automatically. Also, news from the admin panel is published not only in the rss feed, but also on the site in a human-readable format, so the problem arose

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2021-11-11
@ForestAndGarden

If you like, you can combine via Tiny Tiny RSS. Don't forget to set cron to auto-update.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question