{"title":"Generisk datumvisning","version":"5.2","locale":"sv","docname":"ref/class-based-views/generic-date-based","url":"/sv/5.2/ref/class-based-views/generic-date-based/","canonical":"https://djangodocs.dev/sv/5.2/ref/class-based-views/generic-date-based/","summary":"Datumbaserade generiska vyer, som tillhandahålls i django.views.generic.dates, är vyer för att visa drilldown-sidor för datumbaserade data.","html":"<span id=\"generic-date-views\"></span><h1>Generisk datumvisning<a class=\"heading-anchor\" href=\"#module-django.views.generic.dates\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>Datumbaserade generiska vyer, som tillhandahålls i <a class=\"reference internal\" href=\"#module-django.views.generic.dates\" title=\"django.views.generic.dates\"><code class=\"xref py py-mod docutils literal notranslate\">django.views.generic.dates</code></a>, är vyer för att visa drilldown-sidor för datumbaserade data.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Observera</p>\n<p>Några av exemplen på den här sidan utgår från att en <code class=\"docutils literal notranslate\">Artikel</code>-modell har definierats på följande sätt i <code class=\"docutils literal notranslate\">myapp/models.py</code>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.db</span> <span class=\"kn\">import</span> models\n<span class=\"kn\">from</span> <span class=\"nn\">django.urls</span> <span class=\"kn\">import</span> reverse\n\n\n<span class=\"k\">class</span> <span class=\"nc\">Article</span><span class=\"p\">(</span>models<span class=\"o\">.</span>Model<span class=\"p\">):</span>\n    title <span class=\"o\">=</span> models<span class=\"o\">.</span>CharField<span class=\"p\">(</span>max_length<span class=\"o\">=</span><span class=\"mi\">200</span><span class=\"p\">)</span>\n    pub_date <span class=\"o\">=</span> models<span class=\"o\">.</span>DateField<span class=\"p\">()</span>\n\n    <span class=\"k\">def</span> <span class=\"nf\">get_absolute_url</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n        <span class=\"k\">return</span> reverse<span class=\"p\">(</span><span class=\"s2\">&quot;article-detail&quot;</span><span class=\"p\">,</span> kwargs<span class=\"o\">=</span><span class=\"p\">{</span><span class=\"s2\">&quot;pk&quot;</span><span class=\"p\">:</span> <span class=\"bp\">self</span><span class=\"o\">.</span>pk<span class=\"p\">})</span>\n</code></pre></div>\n</aside>\n<section id=\"archiveindexview\">\n<h2><code class=\"docutils literal notranslate\">ArchiveIndexView</code><a class=\"heading-anchor\" href=\"#archiveindexview\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.ArchiveIndexView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">ArchiveIndexView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.ArchiveIndexView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>En indexsida på översta nivån som visar de ”senaste” objekten, efter datum. Objekt med ett datum i <em>framtiden</em> inkluderas inte om du inte ställer in <code class=\"docutils literal notranslate\">allow_future</code> till <code class=\"docutils literal notranslate\">True</code>.</p>\n<p><strong>Ancestors (MRO)</strong></p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectTemplateResponseMixin\" title=\"django.views.generic.list.MultipleObjectTemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectTemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-simple/#django.views.generic.base.TemplateResponseMixin\" title=\"django.views.generic.base.TemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.TemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"#django.views.generic.dates.BaseArchiveIndexView\" title=\"django.views.generic.dates.BaseArchiveIndexView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseArchiveIndexView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView\" title=\"django.views.generic.dates.BaseDateListView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseDateListView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectMixin\" title=\"django.views.generic.list.MultipleObjectMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin\" title=\"django.views.generic.dates.DateMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.DateMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/base/#django.views.generic.base.View\" title=\"django.views.generic.base.View\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.View</code></a></p></li>\n</ul>\n<p><strong>Kontext</strong></p>\n<p>Förutom det sammanhang som tillhandahålls av <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectMixin\" title=\"django.views.generic.list.MultipleObjectMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectMixin</code></a> (via <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView\" title=\"django.views.generic.dates.BaseDateListView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseDateListView</code></a>), kommer mallens sammanhang att vara:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">date_list</code>: Ett <a class=\"reference internal\" href=\"/sv/5.2/ref/models/querysets/#django.db.models.query.QuerySet.dates\" title=\"django.db.models.query.QuerySet.dates\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet</code></a>-objekt som innehåller alla år som har objekt tillgängliga enligt <code class=\"docutils literal notranslate\">queryset</code>, representerade som <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime.datetime</code></a>-objekt, i fallande ordning.</p></li>\n</ul>\n<p><strong>Noter</strong></p>\n<ul class=\"simple\">\n<li><p>Använder ett standardnamn för <code class=\"docutils literal notranslate\">context_object_name</code> på <code class=\"docutils literal notranslate\">latest</code>.</p></li>\n<li><p>Använder standardvärdet <code class=\"docutils literal notranslate\">template_name_suffix</code> för <code class=\"docutils literal notranslate\">_archive</code>.</p></li>\n<li><p>Standard är att tillhandahålla <code class=\"docutils literal notranslate\">date_list</code> per år, men detta kan ändras till månad eller dag med hjälp av attributet <code class=\"docutils literal notranslate\">date_list_period</code>. Detta gäller även för alla underklassvyer.</p></li>\n</ul>\n<p><strong>Exempel myapp/urls.py</strong>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.urls</span> <span class=\"kn\">import</span> path\n<span class=\"kn\">from</span> <span class=\"nn\">django.views.generic.dates</span> <span class=\"kn\">import</span> ArchiveIndexView\n\n<span class=\"kn\">from</span> <span class=\"nn\">myapp.models</span> <span class=\"kn\">import</span> Article\n\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    path<span class=\"p\">(</span>\n        <span class=\"s2\">&quot;archive/&quot;</span><span class=\"p\">,</span>\n        ArchiveIndexView<span class=\"o\">.</span>as_view<span class=\"p\">(</span>model<span class=\"o\">=</span>Article<span class=\"p\">,</span> date_field<span class=\"o\">=</span><span class=\"s2\">&quot;pub_date&quot;</span><span class=\"p\">),</span>\n        name<span class=\"o\">=</span><span class=\"s2\">&quot;article_archive&quot;</span><span class=\"p\">,</span>\n    <span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p><strong>Exempel myapp/article_archive.html</strong>:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">article</span> <span class=\"k\">in</span> <span class=\"nv\">latest</span> <span class=\"cp\">%}</span>\n        <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">article.pub_date</span> <span class=\"cp\">}}</span>: <span class=\"cp\">{{</span> <span class=\"nv\">article.title</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>Detta kommer att mata ut alla artiklar.</p>\n</dd></dl>\n\n</section>\n<section id=\"yeararchiveview\">\n<h2><code class=\"docutils literal notranslate\">ÅrArkivView</code><a class=\"heading-anchor\" href=\"#yeararchiveview\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.YearArchiveView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">YearArchiveView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.YearArchiveView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>En årlig arkivsida som visar alla tillgängliga månader under ett visst år. Objekt med ett datum i <em>framtiden</em> visas inte om du inte ställer in <code class=\"docutils literal notranslate\">allow_future</code> till <code class=\"docutils literal notranslate\">True</code>.</p>\n<p><strong>Ancestors (MRO)</strong></p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectTemplateResponseMixin\" title=\"django.views.generic.list.MultipleObjectTemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectTemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-simple/#django.views.generic.base.TemplateResponseMixin\" title=\"django.views.generic.base.TemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.TemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"#django.views.generic.dates.BaseYearArchiveView\" title=\"django.views.generic.dates.BaseYearArchiveView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseYearArchiveView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.YearMixin\" title=\"django.views.generic.dates.YearMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.YearMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView\" title=\"django.views.generic.dates.BaseDateListView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseDateListView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectMixin\" title=\"django.views.generic.list.MultipleObjectMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin\" title=\"django.views.generic.dates.DateMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.DateMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/base/#django.views.generic.base.View\" title=\"django.views.generic.base.View\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.View</code></a></p></li>\n</ul>\n<dl class=\"py attribute\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.YearArchiveView.make_object_list\">\n<span class=\"sig-name descname\">make_object_list</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.YearArchiveView.make_object_list\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>En boolean som anger om den fullständiga listan över objekt för det här året ska hämtas och skickas till mallen. Om <code class=\"docutils literal notranslate\">True</code>, kommer listan med objekt att göras tillgänglig för kontexten. Om <code class=\"docutils literal notranslate\">False</code>, kommer frågeuppsättningen <code class=\"docutils literal notranslate\">None</code> att användas som objektlista. Som standard är detta <code class=\"docutils literal notranslate\">False</code>.</p>\n</dd></dl>\n\n<dl class=\"py method\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.YearArchiveView.get_make_object_list\">\n<span class=\"sig-name descname\">get_make_object_list</span><span class=\"sig-paren\">(</span><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.YearArchiveView.get_make_object_list\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Bestämmer om en objektlista ska returneras som en del av kontexten. Returnerar <a class=\"reference internal\" href=\"#django.views.generic.dates.YearArchiveView.make_object_list\" title=\"django.views.generic.dates.YearArchiveView.make_object_list\"><code class=\"xref py py-attr docutils literal notranslate\">make_object_list</code></a> som standard.</p>\n</dd></dl>\n\n<p><strong>Kontext</strong></p>\n<p>Förutom det sammanhang som tillhandahålls av <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectMixin\" title=\"django.views.generic.list.MultipleObjectMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectMixin</code></a> (via <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView\" title=\"django.views.generic.dates.BaseDateListView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseDateListView</code></a>), kommer mallens sammanhang att vara:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">date_list</code>: Ett <a class=\"reference internal\" href=\"/sv/5.2/ref/models/querysets/#django.db.models.query.QuerySet.dates\" title=\"django.db.models.query.QuerySet.dates\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet</code></a>-objekt som innehåller alla månader som har objekt tillgängliga enligt <code class=\"docutils literal notranslate\">queryset</code>, representerade som <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime.datetime</code></a>-objekt, i stigande ordning.</p></li>\n<li><p><code class=\"docutils literal notranslate\">year</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar det angivna året.</p></li>\n<li><p><code class=\"docutils literal notranslate\">next_year</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar den första dagen i nästa år, enligt <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView.allow_empty\" title=\"django.views.generic.dates.BaseDateListView.allow_empty\"><code class=\"xref py py-attr docutils literal notranslate\">allow_empty</code></a> och <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin.allow_future\" title=\"django.views.generic.dates.DateMixin.allow_future\"><code class=\"xref py py-attr docutils literal notranslate\">allow_future</code></a>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">previous_year</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar den första dagen i det föregående året, enligt <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView.allow_empty\" title=\"django.views.generic.dates.BaseDateListView.allow_empty\"><code class=\"xref py py-attr docutils literal notranslate\">allow_empty</code></a> och <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin.allow_future\" title=\"django.views.generic.dates.DateMixin.allow_future\"><code class=\"xref py py-attr docutils literal notranslate\">allow_future</code></a>.</p></li>\n</ul>\n<p><strong>Noter</strong></p>\n<ul class=\"simple\">\n<li><p>Använder standardvärdet för <code class=\"docutils literal notranslate\">template_name_suffix</code> <code class=\"docutils literal notranslate\">_archive_year</code>.</p></li>\n</ul>\n<p><strong>Exempel myapp/views.py</strong>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.views.generic.dates</span> <span class=\"kn\">import</span> YearArchiveView\n\n<span class=\"kn\">from</span> <span class=\"nn\">myapp.models</span> <span class=\"kn\">import</span> Article\n\n\n<span class=\"k\">class</span> <span class=\"nc\">ArticleYearArchiveView</span><span class=\"p\">(</span>YearArchiveView<span class=\"p\">):</span>\n    queryset <span class=\"o\">=</span> Article<span class=\"o\">.</span>objects<span class=\"o\">.</span>all<span class=\"p\">()</span>\n    date_field <span class=\"o\">=</span> <span class=\"s2\">&quot;pub_date&quot;</span>\n    make_object_list <span class=\"o\">=</span> <span class=\"kc\">True</span>\n    allow_future <span class=\"o\">=</span> <span class=\"kc\">True</span>\n</code></pre></div>\n<p><strong>Exempel myapp/urls.py</strong>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.urls</span> <span class=\"kn\">import</span> path\n\n<span class=\"kn\">from</span> <span class=\"nn\">myapp.views</span> <span class=\"kn\">import</span> ArticleYearArchiveView\n\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    path<span class=\"p\">(</span><span class=\"s2\">&quot;&lt;int:year&gt;/&quot;</span><span class=\"p\">,</span> ArticleYearArchiveView<span class=\"o\">.</span>as_view<span class=\"p\">(),</span> name<span class=\"o\">=</span><span class=\"s2\">&quot;article_year_archive&quot;</span><span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p><strong>Exempel myapp/article_archive_year.html</strong>:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">date</span> <span class=\"k\">in</span> <span class=\"nv\">date_list</span> <span class=\"cp\">%}</span>\n        <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">date</span><span class=\"o\">|</span><span class=\"nf\">date</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n\n<span class=\"p\">&lt;</span><span class=\"nt\">div</span><span class=\"p\">&gt;</span>\n    <span class=\"p\">&lt;</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>All Articles for <span class=\"cp\">{{</span> <span class=\"nv\">year</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;Y&quot;</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">obj</span> <span class=\"k\">in</span> <span class=\"nv\">object_list</span> <span class=\"cp\">%}</span>\n        <span class=\"p\">&lt;</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n            <span class=\"cp\">{{</span> <span class=\"nv\">obj.title</span> <span class=\"cp\">}}</span> - <span class=\"cp\">{{</span> <span class=\"nv\">obj.pub_date</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;F j, Y&quot;</span> <span class=\"cp\">}}</span>\n        <span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">div</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n</dd></dl>\n\n</section>\n<section id=\"montharchiveview\">\n<h2><code class=\"docutils literal notranslate\">MonthArchiveView</code><a class=\"heading-anchor\" href=\"#montharchiveview\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.MonthArchiveView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">MonthArchiveView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.MonthArchiveView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>En månatlig arkivsida som visar alla objekt under en viss månad. Objekt med ett datum i <em>framtiden</em> visas inte om du inte har ställt in <code class=\"docutils literal notranslate\">allow_future</code> till <code class=\"docutils literal notranslate\">True</code>.</p>\n<p><strong>Ancestors (MRO)</strong></p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectTemplateResponseMixin\" title=\"django.views.generic.list.MultipleObjectTemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectTemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-simple/#django.views.generic.base.TemplateResponseMixin\" title=\"django.views.generic.base.TemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.TemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"#django.views.generic.dates.BaseMonthArchiveView\" title=\"django.views.generic.dates.BaseMonthArchiveView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseMonthArchiveView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.YearMixin\" title=\"django.views.generic.dates.YearMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.YearMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.MonthMixin\" title=\"django.views.generic.dates.MonthMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.MonthMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView\" title=\"django.views.generic.dates.BaseDateListView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseDateListView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectMixin\" title=\"django.views.generic.list.MultipleObjectMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin\" title=\"django.views.generic.dates.DateMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.DateMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/base/#django.views.generic.base.View\" title=\"django.views.generic.base.View\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.View</code></a></p></li>\n</ul>\n<p><strong>Kontext</strong></p>\n<p>Förutom det sammanhang som tillhandahålls av <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectMixin\" title=\"django.views.generic.list.MultipleObjectMixin\"><code class=\"xref py py-class docutils literal notranslate\">MultipleObjectMixin</code></a> (via <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView\" title=\"django.views.generic.dates.BaseDateListView\"><code class=\"xref py py-class docutils literal notranslate\">BaseDateListView</code></a>), kommer mallens sammanhang att vara:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">datum_lista</code>: Ett <a class=\"reference internal\" href=\"/sv/5.2/ref/models/querysets/#django.db.models.query.QuerySet.dates\" title=\"django.db.models.query.QuerySet.dates\"><code class=\"xref py py-meth docutils literal notranslate\">QuerySet</code></a>-objekt som innehåller alla dagar som har objekt tillgängliga i den angivna månaden, enligt <code class=\"docutils literal notranslate\">queryset</code>, representerade som <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.datetime\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">datetime.datetime</code></a>-objekt, i stigande ordning.</p></li>\n<li><p><code class=\"docutils literal notranslate\">month</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar den angivna månaden.</p></li>\n<li><p><code class=\"docutils literal notranslate\">next_month</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar den första dagen i nästa månad, enligt <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView.allow_empty\" title=\"django.views.generic.dates.BaseDateListView.allow_empty\"><code class=\"xref py py-attr docutils literal notranslate\">allow_empty</code></a> och <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin.allow_future\" title=\"django.views.generic.dates.DateMixin.allow_future\"><code class=\"xref py py-attr docutils literal notranslate\">allow_future</code></a>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">previous_month</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar den första dagen i föregående månad, enligt <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView.allow_empty\" title=\"django.views.generic.dates.BaseDateListView.allow_empty\"><code class=\"xref py py-attr docutils literal notranslate\">allow_empty</code></a> och <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin.allow_future\" title=\"django.views.generic.dates.DateMixin.allow_future\"><code class=\"xref py py-attr docutils literal notranslate\">allow_future</code></a>.</p></li>\n</ul>\n<p><strong>Noter</strong></p>\n<ul class=\"simple\">\n<li><p>Använder standardvärdet för <code class=\"docutils literal notranslate\">template_name_suffix</code> <code class=\"docutils literal notranslate\">_archive_month</code>.</p></li>\n</ul>\n<p><strong>Exempel myapp/views.py</strong>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.views.generic.dates</span> <span class=\"kn\">import</span> MonthArchiveView\n\n<span class=\"kn\">from</span> <span class=\"nn\">myapp.models</span> <span class=\"kn\">import</span> Article\n\n\n<span class=\"k\">class</span> <span class=\"nc\">ArticleMonthArchiveView</span><span class=\"p\">(</span>MonthArchiveView<span class=\"p\">):</span>\n    queryset <span class=\"o\">=</span> Article<span class=\"o\">.</span>objects<span class=\"o\">.</span>all<span class=\"p\">()</span>\n    date_field <span class=\"o\">=</span> <span class=\"s2\">&quot;pub_date&quot;</span>\n    allow_future <span class=\"o\">=</span> <span class=\"kc\">True</span>\n</code></pre></div>\n<p><strong>Exempel myapp/urls.py</strong>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.urls</span> <span class=\"kn\">import</span> path\n\n<span class=\"kn\">from</span> <span class=\"nn\">myapp.views</span> <span class=\"kn\">import</span> ArticleMonthArchiveView\n\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    <span class=\"c1\"># Example: /2012/08/</span>\n    path<span class=\"p\">(</span>\n        <span class=\"s2\">&quot;&lt;int:year&gt;/&lt;int:month&gt;/&quot;</span><span class=\"p\">,</span>\n        ArticleMonthArchiveView<span class=\"o\">.</span>as_view<span class=\"p\">(</span>month_format<span class=\"o\">=</span><span class=\"s2\">&quot;%m&quot;</span><span class=\"p\">),</span>\n        name<span class=\"o\">=</span><span class=\"s2\">&quot;archive_month_numeric&quot;</span><span class=\"p\">,</span>\n    <span class=\"p\">),</span>\n    <span class=\"c1\"># Example: /2012/aug/</span>\n    path<span class=\"p\">(</span>\n        <span class=\"s2\">&quot;&lt;int:year&gt;/&lt;str:month&gt;/&quot;</span><span class=\"p\">,</span>\n        ArticleMonthArchiveView<span class=\"o\">.</span>as_view<span class=\"p\">(),</span>\n        name<span class=\"o\">=</span><span class=\"s2\">&quot;archive_month&quot;</span><span class=\"p\">,</span>\n    <span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p><strong>Exempel myapp/article_archive_month.html</strong>:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">article</span> <span class=\"k\">in</span> <span class=\"nv\">object_list</span> <span class=\"cp\">%}</span>\n        <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">article.pub_date</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;F j, Y&quot;</span> <span class=\"cp\">}}</span>: <span class=\"cp\">{{</span> <span class=\"nv\">article.title</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n\n<span class=\"p\">&lt;</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">previous_month</span> <span class=\"cp\">%}</span>\n        Previous Month: <span class=\"cp\">{{</span> <span class=\"nv\">previous_month</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;F Y&quot;</span> <span class=\"cp\">}}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">next_month</span> <span class=\"cp\">%}</span>\n        Next Month: <span class=\"cp\">{{</span> <span class=\"nv\">next_month</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;F Y&quot;</span> <span class=\"cp\">}}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n</dd></dl>\n\n</section>\n<section id=\"weekarchiveview\">\n<h2><code class=\"docutils literal notranslate\">WeekArchiveView</code><a class=\"heading-anchor\" href=\"#weekarchiveview\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.WeekArchiveView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">WeekArchiveView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.WeekArchiveView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>En veckovis arkivsida som visar alla objekt under en viss vecka. Objekt med ett datum i <em>framtiden</em> visas inte om du inte har ställt in <code class=\"docutils literal notranslate\">allow_future</code> till <code class=\"docutils literal notranslate\">True</code>.</p>\n<p><strong>Ancestors (MRO)</strong></p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectTemplateResponseMixin\" title=\"django.views.generic.list.MultipleObjectTemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectTemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-simple/#django.views.generic.base.TemplateResponseMixin\" title=\"django.views.generic.base.TemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.TemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"#django.views.generic.dates.BaseWeekArchiveView\" title=\"django.views.generic.dates.BaseWeekArchiveView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseWeekArchiveView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.YearMixin\" title=\"django.views.generic.dates.YearMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.YearMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.WeekMixin\" title=\"django.views.generic.dates.WeekMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.WeekMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView\" title=\"django.views.generic.dates.BaseDateListView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseDateListView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectMixin\" title=\"django.views.generic.list.MultipleObjectMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin\" title=\"django.views.generic.dates.DateMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.DateMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/base/#django.views.generic.base.View\" title=\"django.views.generic.base.View\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.View</code></a></p></li>\n</ul>\n<p><strong>Kontext</strong></p>\n<p>Förutom det sammanhang som tillhandahålls av <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectMixin\" title=\"django.views.generic.list.MultipleObjectMixin\"><code class=\"xref py py-class docutils literal notranslate\">MultipleObjectMixin</code></a> (via <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView\" title=\"django.views.generic.dates.BaseDateListView\"><code class=\"xref py py-class docutils literal notranslate\">BaseDateListView</code></a>), kommer mallens sammanhang att vara:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">week</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar den första dagen i den angivna veckan.</p></li>\n<li><p><code class=\"docutils literal notranslate\">next_week</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar den första dagen i nästa vecka, enligt <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView.allow_empty\" title=\"django.views.generic.dates.BaseDateListView.allow_empty\"><code class=\"xref py py-attr docutils literal notranslate\">allow_empty</code></a> och <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin.allow_future\" title=\"django.views.generic.dates.DateMixin.allow_future\"><code class=\"xref py py-attr docutils literal notranslate\">allow_future</code></a>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">previous_week</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar den första dagen i föregående vecka, enligt <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView.allow_empty\" title=\"django.views.generic.dates.BaseDateListView.allow_empty\"><code class=\"xref py py-attr docutils literal notranslate\">allow_empty</code></a> och <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin.allow_future\" title=\"django.views.generic.dates.DateMixin.allow_future\"><code class=\"xref py py-attr docutils literal notranslate\">allow_future</code></a>.</p></li>\n</ul>\n<p><strong>Noter</strong></p>\n<ul class=\"simple\">\n<li><p>Använder standardvärdet för <code class=\"docutils literal notranslate\">template_name_suffix</code> <code class=\"docutils literal notranslate\">_archive_week</code>.</p></li>\n<li><p>Attributet <code class=\"docutils literal notranslate\">week_format</code> är en <a class=\"reference external\" href=\"https://docs.python.org/3/library/time.html#time.strptime\" title=\"(in Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\">strptime()</code></a> formatsträng som används för att tolka veckonumret. Följande värden stöds:</p>\n<ul>\n<li><p><code class=\"docutils literal notranslate\">'%U'</code>: Baserat på USA:s veckosystem där veckan börjar på söndag. Detta är standardvärdet.</p></li>\n<li><p><code class=\"docutils literal notranslate\">'%W'</code>: Liknar <code class=\"docutils literal notranslate\">'%U'</code>, men antar att veckan börjar på måndag. Detta är inte samma sak som ISO 8601-veckonumret.</p></li>\n<li><p><code class=\"docutils literal notranslate\">'%V'</code>: ISO 8601 veckonummer där veckan börjar på måndag.</p></li>\n</ul>\n</li>\n</ul>\n<p><strong>Exempel myapp/views.py</strong>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.views.generic.dates</span> <span class=\"kn\">import</span> WeekArchiveView\n\n<span class=\"kn\">from</span> <span class=\"nn\">myapp.models</span> <span class=\"kn\">import</span> Article\n\n\n<span class=\"k\">class</span> <span class=\"nc\">ArticleWeekArchiveView</span><span class=\"p\">(</span>WeekArchiveView<span class=\"p\">):</span>\n    queryset <span class=\"o\">=</span> Article<span class=\"o\">.</span>objects<span class=\"o\">.</span>all<span class=\"p\">()</span>\n    date_field <span class=\"o\">=</span> <span class=\"s2\">&quot;pub_date&quot;</span>\n    week_format <span class=\"o\">=</span> <span class=\"s2\">&quot;%W&quot;</span>\n    allow_future <span class=\"o\">=</span> <span class=\"kc\">True</span>\n</code></pre></div>\n<p><strong>Exempel myapp/urls.py</strong>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.urls</span> <span class=\"kn\">import</span> path\n\n<span class=\"kn\">from</span> <span class=\"nn\">myapp.views</span> <span class=\"kn\">import</span> ArticleWeekArchiveView\n\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    <span class=\"c1\"># Example: /2012/week/23/</span>\n    path<span class=\"p\">(</span>\n        <span class=\"s2\">&quot;&lt;int:year&gt;/week/&lt;int:week&gt;/&quot;</span><span class=\"p\">,</span>\n        ArticleWeekArchiveView<span class=\"o\">.</span>as_view<span class=\"p\">(),</span>\n        name<span class=\"o\">=</span><span class=\"s2\">&quot;archive_week&quot;</span><span class=\"p\">,</span>\n    <span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p><strong>Exempel myapp/article_archive_week.html</strong>:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>Week <span class=\"cp\">{{</span> <span class=\"nv\">week</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s1\">:&#39;W&#39;</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>\n\n<span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">article</span> <span class=\"k\">in</span> <span class=\"nv\">object_list</span> <span class=\"cp\">%}</span>\n        <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">article.pub_date</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;F j, Y&quot;</span> <span class=\"cp\">}}</span>: <span class=\"cp\">{{</span> <span class=\"nv\">article.title</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n\n<span class=\"p\">&lt;</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">previous_week</span> <span class=\"cp\">%}</span>\n        Previous Week: <span class=\"cp\">{{</span> <span class=\"nv\">previous_week</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;W&quot;</span> <span class=\"cp\">}}</span> of year <span class=\"cp\">{{</span> <span class=\"nv\">previous_week</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;Y&quot;</span> <span class=\"cp\">}}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">previous_week</span> <span class=\"k\">and</span> <span class=\"nv\">next_week</span> <span class=\"cp\">%}</span>--<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">next_week</span> <span class=\"cp\">%}</span>\n        Next week: <span class=\"cp\">{{</span> <span class=\"nv\">next_week</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;W&quot;</span> <span class=\"cp\">}}</span> of year <span class=\"cp\">{{</span> <span class=\"nv\">next_week</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;Y&quot;</span> <span class=\"cp\">}}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n<p>I det här exemplet skriver du ut veckonumret. Tänk på att veckonummer som beräknas av mallfiltret <a class=\"reference internal\" href=\"/sv/5.2/ref/templates/builtins/#std-templatefilter-date\"><code class=\"xref std std-tfilter docutils literal notranslate\">date</code></a> med formattecknet <code class=\"docutils literal notranslate\">'W'</code> inte alltid är samma som de som beräknas av <a class=\"reference external\" href=\"https://docs.python.org/3/library/time.html#time.strftime\" title=\"(in Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\">strftime()</code></a> och <a class=\"reference external\" href=\"https://docs.python.org/3/library/time.html#time.strptime\" title=\"(in Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\">strptime()</code></a> med formatsträngen <code class=\"docutils literal notranslate\">'%W'</code>. För år 2015, till exempel, är veckonummer som matas ut av <a class=\"reference internal\" href=\"/sv/5.2/ref/templates/builtins/#std-templatefilter-date\"><code class=\"xref std std-tfilter docutils literal notranslate\">date</code></a> högre med ett jämfört med de som matas ut av <a class=\"reference external\" href=\"https://docs.python.org/3/library/time.html#time.strftime\" title=\"(in Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\">strftime()</code></a>. Det finns ingen motsvarighet till formatsträngen <code class=\"docutils literal notranslate\">'%U'</code> <a class=\"reference external\" href=\"https://docs.python.org/3/library/time.html#time.strftime\" title=\"(in Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\">strftime()</code></a> i <a class=\"reference internal\" href=\"/sv/5.2/ref/templates/builtins/#std-templatefilter-date\"><code class=\"xref std std-tfilter docutils literal notranslate\">date</code></a>. Därför bör du undvika att använda <a class=\"reference internal\" href=\"/sv/5.2/ref/templates/builtins/#std-templatefilter-date\"><code class=\"xref std std-tfilter docutils literal notranslate\">date</code></a> för att generera URL:er för <code class=\"docutils literal notranslate\">WeekArchiveView</code>.</p>\n</dd></dl>\n\n</section>\n<section id=\"dayarchiveview\">\n<h2><code class=\"docutils literal notranslate\">DayArchiveView</code><a class=\"heading-anchor\" href=\"#dayarchiveview\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.DayArchiveView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">DayArchiveView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.DayArchiveView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>En dagarkivsida som visar alla objekt under en viss dag. Dagar i framtiden ger ett 404-fel, oavsett om det finns några objekt för framtida dagar, såvida du inte har ställt in <code class=\"docutils literal notranslate\">allow_future</code> till <code class=\"docutils literal notranslate\">True</code>.</p>\n<p><strong>Ancestors (MRO)</strong></p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectTemplateResponseMixin\" title=\"django.views.generic.list.MultipleObjectTemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectTemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-simple/#django.views.generic.base.TemplateResponseMixin\" title=\"django.views.generic.base.TemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.TemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"#django.views.generic.dates.BaseDayArchiveView\" title=\"django.views.generic.dates.BaseDayArchiveView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseDayArchiveView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.YearMixin\" title=\"django.views.generic.dates.YearMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.YearMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.MonthMixin\" title=\"django.views.generic.dates.MonthMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.MonthMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DayMixin\" title=\"django.views.generic.dates.DayMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.DayMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView\" title=\"django.views.generic.dates.BaseDateListView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseDateListView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectMixin\" title=\"django.views.generic.list.MultipleObjectMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin\" title=\"django.views.generic.dates.DateMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.DateMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/base/#django.views.generic.base.View\" title=\"django.views.generic.base.View\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.View</code></a></p></li>\n</ul>\n<p><strong>Kontext</strong></p>\n<p>Förutom det sammanhang som tillhandahålls av <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectMixin\" title=\"django.views.generic.list.MultipleObjectMixin\"><code class=\"xref py py-class docutils literal notranslate\">MultipleObjectMixin</code></a> (via <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView\" title=\"django.views.generic.dates.BaseDateListView\"><code class=\"xref py py-class docutils literal notranslate\">BaseDateListView</code></a>), kommer mallens sammanhang att vara:</p>\n<ul class=\"simple\">\n<li><p><code class=\"docutils literal notranslate\">day</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar den angivna dagen.</p></li>\n<li><p><code class=\"docutils literal notranslate\">next_day</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar nästa dag, enligt <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView.allow_empty\" title=\"django.views.generic.dates.BaseDateListView.allow_empty\"><code class=\"xref py py-attr docutils literal notranslate\">allow_empty</code></a> och <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin.allow_future\" title=\"django.views.generic.dates.DateMixin.allow_future\"><code class=\"xref py py-attr docutils literal notranslate\">allow_future</code></a>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">previous_day</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar föregående dag, enligt <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView.allow_empty\" title=\"django.views.generic.dates.BaseDateListView.allow_empty\"><code class=\"xref py py-attr docutils literal notranslate\">allow_empty</code></a> och <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin.allow_future\" title=\"django.views.generic.dates.DateMixin.allow_future\"><code class=\"xref py py-attr docutils literal notranslate\">allow_future</code></a>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">next_month</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar den första dagen i nästa månad, enligt <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView.allow_empty\" title=\"django.views.generic.dates.BaseDateListView.allow_empty\"><code class=\"xref py py-attr docutils literal notranslate\">allow_empty</code></a> och <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin.allow_future\" title=\"django.views.generic.dates.DateMixin.allow_future\"><code class=\"xref py py-attr docutils literal notranslate\">allow_future</code></a>.</p></li>\n<li><p><code class=\"docutils literal notranslate\">previous_month</code>: Ett <a class=\"reference external\" href=\"https://docs.python.org/3/library/datetime.html#datetime.date\" title=\"(in Python v3.14)\"><code class=\"xref py py-class docutils literal notranslate\">date</code></a>-objekt som representerar den första dagen i föregående månad, enligt <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView.allow_empty\" title=\"django.views.generic.dates.BaseDateListView.allow_empty\"><code class=\"xref py py-attr docutils literal notranslate\">allow_empty</code></a> och <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin.allow_future\" title=\"django.views.generic.dates.DateMixin.allow_future\"><code class=\"xref py py-attr docutils literal notranslate\">allow_future</code></a>.</p></li>\n</ul>\n<p><strong>Noter</strong></p>\n<ul class=\"simple\">\n<li><p>Använder standardvärdet för <code class=\"docutils literal notranslate\">template_name_suffix</code> <code class=\"docutils literal notranslate\">_archive_day</code>.</p></li>\n</ul>\n<p><strong>Exempel myapp/views.py</strong>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.views.generic.dates</span> <span class=\"kn\">import</span> DayArchiveView\n\n<span class=\"kn\">from</span> <span class=\"nn\">myapp.models</span> <span class=\"kn\">import</span> Article\n\n\n<span class=\"k\">class</span> <span class=\"nc\">ArticleDayArchiveView</span><span class=\"p\">(</span>DayArchiveView<span class=\"p\">):</span>\n    queryset <span class=\"o\">=</span> Article<span class=\"o\">.</span>objects<span class=\"o\">.</span>all<span class=\"p\">()</span>\n    date_field <span class=\"o\">=</span> <span class=\"s2\">&quot;pub_date&quot;</span>\n    allow_future <span class=\"o\">=</span> <span class=\"kc\">True</span>\n</code></pre></div>\n<p><strong>Exempel myapp/urls.py</strong>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.urls</span> <span class=\"kn\">import</span> path\n\n<span class=\"kn\">from</span> <span class=\"nn\">myapp.views</span> <span class=\"kn\">import</span> ArticleDayArchiveView\n\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    <span class=\"c1\"># Example: /2012/nov/10/</span>\n    path<span class=\"p\">(</span>\n        <span class=\"s2\">&quot;&lt;int:year&gt;/&lt;str:month&gt;/&lt;int:day&gt;/&quot;</span><span class=\"p\">,</span>\n        ArticleDayArchiveView<span class=\"o\">.</span>as_view<span class=\"p\">(),</span>\n        name<span class=\"o\">=</span><span class=\"s2\">&quot;archive_day&quot;</span><span class=\"p\">,</span>\n    <span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p><strong>Exempel myapp/article_archive_day.html</strong>:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">day</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>\n\n<span class=\"p\">&lt;</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">for</span> <span class=\"nv\">article</span> <span class=\"k\">in</span> <span class=\"nv\">object_list</span> <span class=\"cp\">%}</span>\n        <span class=\"p\">&lt;</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">article.pub_date</span><span class=\"o\">|</span><span class=\"nf\">date</span><span class=\"s2\">:&quot;F j, Y&quot;</span> <span class=\"cp\">}}</span>: <span class=\"cp\">{{</span> <span class=\"nv\">article.title</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">li</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endfor</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">ul</span><span class=\"p\">&gt;</span>\n\n<span class=\"p\">&lt;</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">previous_day</span> <span class=\"cp\">%}</span>\n        Previous Day: <span class=\"cp\">{{</span> <span class=\"nv\">previous_day</span> <span class=\"cp\">}}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">previous_day</span> <span class=\"k\">and</span> <span class=\"nv\">next_day</span> <span class=\"cp\">%}</span>--<span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">if</span> <span class=\"nv\">next_day</span> <span class=\"cp\">%}</span>\n        Next Day: <span class=\"cp\">{{</span> <span class=\"nv\">next_day</span> <span class=\"cp\">}}</span>\n    <span class=\"cp\">{%</span> <span class=\"k\">endif</span> <span class=\"cp\">%}</span>\n<span class=\"p\">&lt;/</span><span class=\"nt\">p</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n</dd></dl>\n\n</section>\n<section id=\"todayarchiveview\">\n<h2><code class=\"docutils literal notranslate\">TodayArchiveView</code><a class=\"heading-anchor\" href=\"#todayarchiveview\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.TodayArchiveView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">TodayArchiveView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.TodayArchiveView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>En dagarkivsida som visar alla objekt för <em>today</em>. Detta är exakt samma sak som <a class=\"reference internal\" href=\"#django.views.generic.dates.DayArchiveView\" title=\"django.views.generic.dates.DayArchiveView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.DayArchiveView</code></a>, förutom att dagens datum används istället för argumenten <code class=\"docutils literal notranslate\">år</code>/<code class=\"docutils literal notranslate\">månad</code>/<code class=\"docutils literal notranslate\">dag</code>.</p>\n<p><strong>Ancestors (MRO)</strong></p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectTemplateResponseMixin\" title=\"django.views.generic.list.MultipleObjectTemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectTemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-simple/#django.views.generic.base.TemplateResponseMixin\" title=\"django.views.generic.base.TemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.TemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"#django.views.generic.dates.BaseTodayArchiveView\" title=\"django.views.generic.dates.BaseTodayArchiveView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseTodayArchiveView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"#django.views.generic.dates.BaseDayArchiveView\" title=\"django.views.generic.dates.BaseDayArchiveView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseDayArchiveView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.YearMixin\" title=\"django.views.generic.dates.YearMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.YearMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.MonthMixin\" title=\"django.views.generic.dates.MonthMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.MonthMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DayMixin\" title=\"django.views.generic.dates.DayMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.DayMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.BaseDateListView\" title=\"django.views.generic.dates.BaseDateListView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseDateListView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectMixin\" title=\"django.views.generic.list.MultipleObjectMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.list.MultipleObjectMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin\" title=\"django.views.generic.dates.DateMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.DateMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/base/#django.views.generic.base.View\" title=\"django.views.generic.base.View\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.View</code></a></p></li>\n</ul>\n<p><strong>Noter</strong></p>\n<ul class=\"simple\">\n<li><p>Använder standardvärdet <code class=\"docutils literal notranslate\">template_name_suffix</code> <code class=\"docutils literal notranslate\">_archive_today</code>.</p></li>\n</ul>\n<p><strong>Exempel myapp/views.py</strong>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.views.generic.dates</span> <span class=\"kn\">import</span> TodayArchiveView\n\n<span class=\"kn\">from</span> <span class=\"nn\">myapp.models</span> <span class=\"kn\">import</span> Article\n\n\n<span class=\"k\">class</span> <span class=\"nc\">ArticleTodayArchiveView</span><span class=\"p\">(</span>TodayArchiveView<span class=\"p\">):</span>\n    queryset <span class=\"o\">=</span> Article<span class=\"o\">.</span>objects<span class=\"o\">.</span>all<span class=\"p\">()</span>\n    date_field <span class=\"o\">=</span> <span class=\"s2\">&quot;pub_date&quot;</span>\n    allow_future <span class=\"o\">=</span> <span class=\"kc\">True</span>\n</code></pre></div>\n<p><strong>Exempel myapp/urls.py</strong>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.urls</span> <span class=\"kn\">import</span> path\n\n<span class=\"kn\">from</span> <span class=\"nn\">myapp.views</span> <span class=\"kn\">import</span> ArticleTodayArchiveView\n\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    path<span class=\"p\">(</span><span class=\"s2\">&quot;today/&quot;</span><span class=\"p\">,</span> ArticleTodayArchiveView<span class=\"o\">.</span>as_view<span class=\"p\">(),</span> name<span class=\"o\">=</span><span class=\"s2\">&quot;archive_today&quot;</span><span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<aside class=\"admonition-where-is-the-example-template-for-todayarchiveview admonition\" role=\"note\">\n<p class=\"admonition-title\">Var finns exempelmallen för <code class=\"docutils literal notranslate\">TodayArchiveView</code>?</p>\n<p>Denna vy använder som standard samma mall som <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/flattened-index/#DayArchiveView\" title=\"DayArchiveView\"><code class=\"xref py py-class docutils literal notranslate\">DayArchiveView</code></a>, som finns i det föregående exemplet. Om du behöver en annan mall, ställ in attributet <code class=\"docutils literal notranslate\">template_name</code> till namnet på den nya mallen.</p>\n</aside>\n</dd></dl>\n\n</section>\n<section id=\"datedetailview\">\n<h2><code class=\"docutils literal notranslate\">DateDetailView</code><a class=\"heading-anchor\" href=\"#datedetailview\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.DateDetailView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">DateDetailView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.DateDetailView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>En sida som representerar ett enskilt objekt. Om objektet har ett datumvärde i framtiden kommer vyn att ge ett 404-fel som standard, såvida du inte ställer in <code class=\"docutils literal notranslate\">allow_future</code> till <code class=\"docutils literal notranslate\">True</code>.</p>\n<p><strong>Ancestors (MRO)</strong></p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectTemplateResponseMixin\" title=\"django.views.generic.detail.SingleObjectTemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.detail.SingleObjectTemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-simple/#django.views.generic.base.TemplateResponseMixin\" title=\"django.views.generic.base.TemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.TemplateResponseMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"#django.views.generic.dates.BaseDateDetailView\" title=\"django.views.generic.dates.BaseDateDetailView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.BaseDateDetailView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.YearMixin\" title=\"django.views.generic.dates.YearMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.YearMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.MonthMixin\" title=\"django.views.generic.dates.MonthMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.MonthMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DayMixin\" title=\"django.views.generic.dates.DayMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.DayMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-date-based/#django.views.generic.dates.DateMixin\" title=\"django.views.generic.dates.DateMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.dates.DateMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/generic-display/#django.views.generic.detail.BaseDetailView\" title=\"django.views.generic.detail.BaseDetailView\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.detail.BaseDetailView</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectMixin\" title=\"django.views.generic.detail.SingleObjectMixin\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.detail.SingleObjectMixin</code></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/base/#django.views.generic.base.View\" title=\"django.views.generic.base.View\"><code class=\"xref py py-class docutils literal notranslate\">django.views.generic.base.View</code></a></p></li>\n</ul>\n<p><strong>Kontext</strong></p>\n<ul class=\"simple\">\n<li><p>Innehåller det enskilda objekt som är associerat med den <code class=\"docutils literal notranslate\">modell</code> som anges i <code class=\"docutils literal notranslate\">DateDetailView</code>.</p></li>\n</ul>\n<p><strong>Noter</strong></p>\n<ul class=\"simple\">\n<li><p>Använder standardvärdet <code class=\"docutils literal notranslate\">template_name_suffix</code> för <code class=\"docutils literal notranslate\">_detail</code>.</p></li>\n</ul>\n<p><strong>Exempel myapp/urls.py</strong>:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span> <span class=\"nn\">django.urls</span> <span class=\"kn\">import</span> path\n<span class=\"kn\">from</span> <span class=\"nn\">django.views.generic.dates</span> <span class=\"kn\">import</span> DateDetailView\n\nurlpatterns <span class=\"o\">=</span> <span class=\"p\">[</span>\n    path<span class=\"p\">(</span>\n        <span class=\"s2\">&quot;&lt;int:year&gt;/&lt;str:month&gt;/&lt;int:day&gt;/&lt;int:pk&gt;/&quot;</span><span class=\"p\">,</span>\n        DateDetailView<span class=\"o\">.</span>as_view<span class=\"p\">(</span>model<span class=\"o\">=</span>Article<span class=\"p\">,</span> date_field<span class=\"o\">=</span><span class=\"s2\">&quot;pub_date&quot;</span><span class=\"p\">),</span>\n        name<span class=\"o\">=</span><span class=\"s2\">&quot;archive_date_detail&quot;</span><span class=\"p\">,</span>\n    <span class=\"p\">),</span>\n<span class=\"p\">]</span>\n</code></pre></div>\n<p><strong>Exempel myapp/article_detail.html</strong>:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"p\">&lt;</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span><span class=\"cp\">{{</span> <span class=\"nv\">object.title</span> <span class=\"cp\">}}</span><span class=\"p\">&lt;/</span><span class=\"nt\">h1</span><span class=\"p\">&gt;</span>\n</code></pre></div>\n</dd></dl>\n\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Observera</p>\n<p>Alla generiska vyer som anges ovan har matchande <code class=\"docutils literal notranslate\">Base</code>-vyer som bara skiljer sig åt genom att de inte innehåller <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-multiple-object/#django.views.generic.list.MultipleObjectTemplateResponseMixin\" title=\"django.views.generic.list.MultipleObjectTemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">MultipleObjectTemplateResponseMixin</code></a> (för arkivvyerna) eller <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectTemplateResponseMixin\" title=\"django.views.generic.detail.SingleObjectTemplateResponseMixin\"><code class=\"xref py py-class docutils literal notranslate\">SingleObjectTemplateResponseMixin</code></a> (för <a class=\"reference internal\" href=\"/sv/5.2/ref/class-based-views/flattened-index/#DateDetailView\" title=\"DateDetailView\"><code class=\"xref py py-class docutils literal notranslate\">DateDetailView</code></a>):</p>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.BaseArchiveIndexView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">BaseArchiveIndexView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.BaseArchiveIndexView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.BaseYearArchiveView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">BaseYearArchiveView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.BaseYearArchiveView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.BaseMonthArchiveView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">BaseMonthArchiveView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.BaseMonthArchiveView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.BaseWeekArchiveView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">BaseWeekArchiveView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.BaseWeekArchiveView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.BaseDayArchiveView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">BaseDayArchiveView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.BaseDayArchiveView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.BaseTodayArchiveView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">BaseTodayArchiveView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.BaseTodayArchiveView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.views.generic.dates.BaseDateDetailView\">\n<em class=\"property\"><span class=\"k\">class</span> </em><span class=\"sig-name descname\">BaseDateDetailView</span><a class=\"heading-anchor\" href=\"#django.views.generic.dates.BaseDateDetailView\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd></dd></dl>\n\n</aside>\n</section>","rootId":"module-django.views.generic.dates","toc":[{"title":"ArchiveIndexView","anchor":"archiveindexview","children":[]},{"title":"ÅrArkivView","anchor":"yeararchiveview","children":[]},{"title":"MonthArchiveView","anchor":"montharchiveview","children":[]},{"title":"WeekArchiveView","anchor":"weekarchiveview","children":[]},{"title":"DayArchiveView","anchor":"dayarchiveview","children":[]},{"title":"TodayArchiveView","anchor":"todayarchiveview","children":[]},{"title":"DateDetailView","anchor":"datedetailview","children":[]}],"breadcrumbs":[{"docname":"ref/index","title":"API-referens","url":"/sv/5.2/ref/"},{"docname":"ref/class-based-views/index","title":"Inbyggt API för klassbaserade vyer","url":"/sv/5.2/ref/class-based-views/"}],"prev":{"docname":"ref/class-based-views/generic-editing","title":"Generiska redigeringsvyer","url":"/sv/5.2/ref/class-based-views/generic-editing/"},"next":{"docname":"ref/class-based-views/mixins","title":"Klassbaserade vy-mixins","url":"/sv/5.2/ref/class-based-views/mixins/"},"formats":{"html":"/sv/5.2/ref/class-based-views/generic-date-based/","markdown":"/sv/5.2/ref/class-based-views/generic-date-based.md","json":"/sv/5.2/ref/class-based-views/generic-date-based.json"},"source":"https://github.com/django/django/blob/stable/5.2.x/docs/ref/class-based-views/generic-date-based.txt","official":"https://docs.djangoproject.com/sv/5.2/ref/class-based-views/generic-date-based/","inVersions":["6.1","6.0","5.2"],"inLocales":["en","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}