Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8938751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:42:08+00:00 2026-06-15T10:42:08+00:00

When I do the exercises on the book named Practical Django Projects,I meet some

  • 0

When I do the exercises on the book named Practical Django Projects,I meet some problem.When I click the Url about detail with my article,It return a error.
urls.py

url(r'^weblog/$','django.views.generic.date_based.archive_index',entry_info_dict),
url(r'^weblog/(P<year>\d{4}/$)','django.views.generic.date_based.archive_year', entry_info_dict),
url(r'^weblog/(P<year>\d{4}/(P<month>\w{3})/$)','django.views.generic.date_based.archive_month', entry_info_dict),
url(r'^weblog/(P<year>\d{4}/(P<month>\w{3})/(P<day>\d{2})/$)','django.views.generic.date_based.archive_day', entry_info_dict),
url(r'^weblog/(?P<year>\d{4}/(?P<month>\w{3})/(P<day>\d{2})/(P<slug>[-\w]+)/$)',"blogCategory.views.entry_detail"),

views.py

def entry_detail(request, year, month, day, slug):
    date_stamp=time.strptime(year+month+day, "%Y%b%d")
    pub_date=datetime.date(*date_stamp[:3])
    entry=get_object_or_404(Entry,pub_date__year=pub_date.year,
        pub_date__month=pub_date.month,
        pub_date__day=pub_date.day,
        slug=slug)
    return render_to_response('Entry/entry_detail.html',{'entry': entry })

Error:

Traceback :
ValueError at /weblog/2012/dec/04/test22/

time data u'2012/dec/04/test22/dec04' does not match format '%Y%b%d'

Request Method:     GET
Request URL:    /weblog/2012/dec/04/test22/
Django Version:     1.4.1
Exception Type:     ValueError
Exception Value:    

time data u'2012/dec/04/test22/dec04' does not match format '%Y%b%d'

Exception Location:     /usr/lib/python2.7/_strptime.py in _strptime, line 325
Python Executable:  /usr/bin/python
Python Version:     2.7.3
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:42:09+00:00Added an answer on June 15, 2026 at 10:42 am

    The wrong data is being passed to strptime see here:

    >>> time.strptime('2012dec04','%Y%b%d')
    time.struct_time(tm_year=2012, tm_mon=12, tm_mday=4, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=1, tm_yday=339, tm_isdst=-1)
    >>> time.strptime('2012/dec/04/test22/dec04','%Y%b%d')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_strptime.py", line 454, in _strptime_time
        return _strptime(data_string, format)[0]
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_strptime.py", line 325, in _strptime
        (data_string, format))
    ValueError: time data '2012/dec/04/test22/dec04' does not match format '%Y%b%d'
    >>> 
    

    And the reason is because your first group isn’t closed:

    # yours
    url(r'^weblog/(?P<year>\d{4}/(?P<month>\w{3})/(P<day>\d{2})/(P<slug>[-\w]+)/$)',"blogCategory.views.entry_detail"),
    
    # change to
    url(r'^weblog/(?P<year>\d{4})/(?P<month>\w{3})/(P<day>\d{2})/(P<slug>[-\w]+)/$',"blogCategory.views.entry_detail"),
    

    You had the first group closing around the $ instead of before the first /

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing some exercises in my object-oriented javascript book, I notice that this:
I'm currently working through some exercises in a c++ book, which uses text based
I am doing some exercises from the book Thinking In Java . I have
The book I'm reading about Erlang has exercises in the back of it and
As always being this problem comes from a book's exercises. Neither I am not
I have some java book and i'm doing exercises. But right now i'm stuck
I'm going through exercises of a C++ book. For each exercise I want to
While solving exercises from the K&R C book, I stumbled upon the exercise 2.1.
I'm reading the Llama ( Learning Perl ) book, and working on the exercises.
I'm trying out several exercises from a Java programming book. I have the code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.