о компьютерах, гаджетах и программировании."
                  
                  
                      link = get_site_address()
                  
                  
                      description = "Новости, статьи, фотографии, видео о компьютерах и программировании."
                  
                  
                  
                  
                  
                      def items(self):
                  
                  
                          # All evergreen posts and fresh news (just exclude old news).
                  
                  
                  
                  
                  
                          # Django taggit doesn't support excluding, only filtering. (https://django-taggit.readthedocs.io/en/latest/api.html#filtering)
                  
                  
                          # Therefore we have to exclude items via an id list.
                  
                  
                          excluded_items = Post.published.filter(tags__slug__in=[SPECIAL_TAGS.NEWS.value],
                  
                  
                                                                 updated__lte=timezone.now()-timedelta(days=NEWS_LIFESPAN))
                  
                  
                  
                  
                  
                          return Post.published.exclude(id__in=get_id_list(excluded_items))[:NUMBER_OF_ITEMS]
                  
                  
                  
                  
                  
                  
                  
                  
                      def item_title(self, item):
                  
                  
                          return item.title
                  
                  
                  
                  
                  
                      def item_description(self, item):
                  
                  
                          return item.description
                  
                  
                  
                  
                  
                      def item_categories(self, item):
                  
                  
                          return (item.category.title,)
                  
                  
                  
                  
                  
                      feed_copyright = 'Все права защищены (c) {}, {}'.format(timezone.now().year,
                  
                  
                                                                              get_site_address())
                  
                  
                  
                  
                  
                      def item_enclosure_url(self, item):
                  
                  
                          featured_image = item.get_featured_image()
                  
                  
                          img_field = getattr(featured_image, ENCLOSURE_WIDTH)
                  
                  
                          enclosure_url = img_field.url
                  
                  
                          return enclosure_url
                  
                  
                  
                  
                  
                      def item_enclosure_mime_type(self, item):
                  
                  
                          featured_image = item.get_featured_image()
                  
                  
                          img_field = getattr(featured_image, ENCLOSURE_WIDTH)
                  
                  
                          _, ext = img_field.name.split(".")
                  
                  
                          mime_type = get_mime_type(ext)
                  
                  
                          return mime_type
                  
                  
                  
                  
                  
                      def item_enclosure_length(self, item):
                  
                  
                          featured_image = item.get_featured_image()
                  
                  
                          img_field = getattr(featured_image, ENCLOSURE_WIDTH)
                  
                  
                          return img_field.size
                  
                  
                  
                  
                  
                      def item_pubdate(self, item):
                  
                  
                          return item.created
                  
                  
                  
                  
                  
                      def item_updateddate(self, item):
                  
                  
                          return item.updated
                  
                  
                  
                  
                  
                  Результат:
                  
                  
                  
                  
                  
                  <?xml version="1.0" encoding="utf-8"?>
                  
                  
                  <rss version="2.0"
                  
                  
                      xmlns:atom="http://www.w3.org/2005/Atom">
                  
                  
                      <channel>
                  
                  
                          <title>Pcask.ru: все о компьютерах, гаджетах и программировании.</title>
                  
                  
                          <link>http://localhost:8000</link>
                  
                  
                          <description>Новости, статьи, фотографии, видео о компьютерах и программировании.</description>
                  
                  
                          <atom:link href="http://localhost:8000/rss/" rel="self"></atom:link>
                  
                  
                          <language>ru-RU</language>
                  
                  
                          <copyright>Все права защищены (c) 2020, </copyright>
                  
                  
                          <lastBuildDate>Mon, 13 Jul 2020 00:00:00 +0000</lastBuildDate>
                  
                  
                          <item>
                  
                  
                              <title>6ffd0cc4-c4cb-11ea-b89d-5404a66bf801</title>
                  
                  
                              <link>http://localhost:8000/linux/6ffd0cc4-c4cb-11ea-b89d-5404a66bf801/</link>
                  
                  
                              <description>1</description>
                  
                  
                              <pubDate>Sun, 12 Jul 2020 00:00:00 +0000</pubDate>
                  
                  
                              <guid>http://localhost:8000/linux/6ffd0cc4-c4cb-11ea-b89d-5404a66bf801/</guid>
                  
                  
                              <enclosure length="15302" type="image/jpg" url="/media/raster_image/6w2RnwFGB2qv3LoQ9hafvf/350_1x-c63dTm9ByBxb8wYv2Tb6Md.jpg"></enclosure>
                  
                  
                              <category>Linux</category>
                  
                  
                          </item>
                  
                  
                          <item>
                  
                  
                              <title>6ffd0cc5-c4cb-11ea-b89d-5404a66bf801</title>
                  
                  
                              <link>http://localhost:8000/linux/6ffd0cc5-c4cb-11ea-b89d-5404a66bf801/</link>
                  
                  
                              <description>1</description>
                  
                  
                              <pubDate>Sun, 12 Jul 2020 00:00:00 +0000</pubDate>
                  
                  
                              <guid>http://localhost:8000/linux/6ffd0cc5-c4cb-11ea-b89d-5404a66bf801/</guid>
                  
                  
                              <enclosure length="15302" type="image/jpg" url="/media/raster_image/6w2RnwFGB2qv3LoQ9hafvf/350_1x-c63dTm9ByBxb8wYv2Tb6Md.jpg"></enclosure>
                  
                  
                              <category>Linux</category>
                  
                  
                          </item>
                  
                  
                  ...
                  
                  
                  
                  
                  
                  Скажите, пожалуйста, почему updatedate не попадает в фид?
                  
                  
                
ну чтож ты делаешь? ну скинь на пасту
Обсуждают сегодня