March 2020
Intermediate to advanced
608 pages
17h 17m
English
Now, we will add the RSS feed to the music app:
# myproject/apps/music/feeds.pyfrom django.contrib.syndication.views import Feedfrom django.urls import reversefrom .models import Songfrom .forms import SongFilterFormclass SongFeed(Feed): description_template = "music/feeds/song_description.html" def get_object(self, request, *args, **kwargs): form = SongFilterForm(data=request.GET) obj = {} if form.is_valid(): obj = {"query_string": request.META["QUERY_STRING"]} for field in ["artist"]: value = form.cleaned_data[field] obj[field] = value return obj def title(self, obj): the_title = "Music" artist = obj.get("artist") if artist: the_title = f"Music by ...