title: Implementing a yearly, monthly Archive in Django
body: <p>I have built archives as such before on separate pages of my sites. However, Django does not want to cooperate with me this time it seems.</p>
  
  <pre><code>class IndexView(ArchiveIndexView):
      template_name = 'cms/blog_base.html'
      date_field = 'pub_date'
      latest = '20'
      model = Entry
  
  In template {% for year in date_list %} {{ year|date:"Y" }} gives me a date relating to none of my entries. {% for entry in object_list % } {{ entry.pub_date|date:"Y" }} obviously outputs the correct date for the entry but as the entries grow I can only imagine it will continue to duplicate the years and months.
  </code></pre>
  
  <p>So what am I doing wrong? What do I have to do in ArchiveIndexView and template tag wise in order to relate the dates to my set of entries? In the past they were on separate pages and thus filtered by the regex in the url conf. One solution I saw was to create a custom manager using some raw SQL is that what I am looking at? If so I will just reconsider this all together. Thanks to the community in advance.</p>
  
  <p>UPDATE: Example: What I am wanting on my home page is something similar to what is on this page <a href="https://unweb.me/blog/monthly-archives-on-Django" rel="nofollow">https://unweb.me/blog/monthly-archives-on-Django</a>  I am also now thinking of trying their solution as it seems like a nice UI/UX. However, I am a simple person and would love to take the simple route if there is one.</p>