0

I'm practicing django with "Practical Django 2nd edition" book, which is based on django 1.1 I installed django 1.5 so I should figure out the changes between django's versions and write the right code (thanx django documentation)

Generic views changed a lot in django 1.5 but finally I got it. I have four urls in my urls.py as below:

urlpatterns = patterns('',
    url(r'^(?P<year>\d{4})/$', EntryYearArchiveView.as_view(), name='coltrane/Entry_Archive_year'),
    url(r'^(?P<year>\d{4})/(?P<month>\w{3})/$', EntryMonthArchiveView.as_view(),name='coltrane/Entry_month_Archive'),
    url(r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$',
        EntryDateDetailView.as_view(), name='coltrane/Entry_Date_Detail'),
    url(r'$', ArchiveIndexView.as_view(model=Entry, date_field="pub_date"), name='coltrane/Entry_Archive'),
)

and views for each url. As you can see ArchiveViewIndex's url is just a $ sign so the address example.com/weblog/ should run this. And the EntryYearArchiveView gets a year. but something is wrong! the address of example.com/weblog/2013/ still runs ArchiveIndexView but not EntryYearArchiveView. The EntryMonthArchiveView goes wrong too. The name of YearArchive template is Entry_archive_year as supposed to be. What I'm messing here?

karthikr
  • 97,368
  • 26
  • 197
  • 188
Lumos Maxima
  • 75
  • 1
  • 1
  • 3

1 Answers1

0

Marking comment as an answer for future reference.

change the last URL from

url(r'$', ArchiveIndexView.as_view(model=Entry, date_field="pub_date"), name='coltrane/Entry_Archive'),

to

url(r'^$', ArchiveIndexView.as_view(model=Entry, date_field="pub_date"), name='coltrane/Entry_Archive'),

for it to match URL patterns correctly.

karthikr
  • 97,368
  • 26
  • 197
  • 188