feed: Add basic rss feed

This commit is contained in:
moanos [he/him] 2024-04-14 16:48:07 +02:00
parent 3fec80f5a7
commit 1e60a14a81
3 changed files with 23 additions and 1 deletions

View File

@ -0,0 +1,20 @@
from django.contrib.syndication.views import Feed
from django.urls import reverse
from .models import AdoptionNotice
class LatestAdoptionNoticesFeed(Feed):
title = "Nptfellchen"
link = "/rss/"
description = "Updates zu neuen Vermittlungen."
def items(self):
return AdoptionNotice.objects.order_by("-created_at")[:5]
def item_title(self, item):
return item.name
def item_description(self, item):
return item.description

View File

@ -10,7 +10,7 @@
<a class="nav-link " href="{% url "search" %}"><i class="fas fa-search"></i> Suchen</a> <a class="nav-link " href="{% url "search" %}"><i class="fas fa-search"></i> Suchen</a>
<a class="nav-link " href="{% url "add-adoption" %}"><i class="fas fa-"></i> Vermittlung hinzufügen</a> <a class="nav-link " href="{% url "add-adoption" %}"><i class="fas fa-"></i> Vermittlung hinzufügen</a>
<a class="nav-link " href="{% url "about" %}"><i class="fas fa-info"></i> Über uns</a> <a class="nav-link " href="{% url "about" %}"><i class="fas fa-info"></i> Über uns</a>
<a class="nav-link " href=""><i class="fas fa-feather"></i> RSS</a> <a class="nav-link " href="{% url "rss" %}"><i class="fas fa-feather"></i> RSS</a>
</nav> </nav>
<div class="header-right"> <div class="header-right">

View File

@ -2,11 +2,13 @@ from django.urls import path, include
from django_registration.backends.activation.views import RegistrationView from django_registration.backends.activation.views import RegistrationView
from .forms import CustomRegistrationForm from .forms import CustomRegistrationForm
from .feeds import LatestAdoptionNoticesFeed
from . import views from . import views
urlpatterns = [ urlpatterns = [
path("", views.index, name="index"), path("", views.index, name="index"),
path("rss/", LatestAdoptionNoticesFeed(), name="rss"),
# ex: /animal/5/ # ex: /animal/5/
path("<int:animal_id>/", views.animal_detail, name="animal-detail"), path("<int:animal_id>/", views.animal_detail, name="animal-detail"),
# ex: /adoption_notice/7/ # ex: /adoption_notice/7/