Django calendar error

22 views
Skip to first unread message

hito koto

unread,
May 7, 2014, 7:12:59 AM5/7/14
to django...@googlegroups.com
I hava also have some error ,
Why ? i did import calendar!


ViewDoesNotExist at /admin/auth/user/

Could not import tcsarticle.views.calendar. View is not callable.
Request Method: GET
Request URL: http://admin/auth/user/
Django Version: 1.6.2
Exception Type: ViewDoesNotExist
Exception Value:
Could not importrticle.views.calendar. View is not callable.
Exception Location: /usr/lib/python2.6/site-packages/django/core/urlresolvers.py in get_callable, line 112
Python Executable: /usr/bin/python

TypeError at /articles/month

month() takes at least 3 arguments (1 given)
Request Method: GET
Request URL: http://articles/month
Django Version: 1.6.2
Exception Type: TypeError
Exception Value:
month() takes at least 3 arguments (1 given)
Exception Location: /usr/lib/python2.6/site-packages/django/core/handlers/base.py in get_response, line 114
Python Executable: /usr/bin/python
Python Version: 2.6.

This is my Views.py:

from datetime import date, datetime, timedelta
import calendar

def month(request, year, month, change=None):
    year, month = int(year), int(month)
    if change in ("next", "prev"):
        now, mdelta = date(year, month, 15), timedelta(days=31)
        if change == "next":   mod = mdelta
        elif change == "prev": mod = -mdelta

        year, month = (now+mod).timetuple()[:2]

    cal = calendar.Calendar()
    month_days = cal.itermonthdays(year, month)
    nyear, nmonth, nday = time.localtime()[:3]
    lst = [[]]
    week = 0

    for day in month_days:
        entries = current = False   # are there entries for this day; current day?
        if day:
            entries = User.objects.filter(date__year=year, date__month=month, date__day=day)
            if day == nday and year == nyear and month == nmonth:
                current = True

        lst[week].append((day, entries, current))
        if len(lst[week]) == 7:
            lst.append([])
            week += 1

    return render_to_response("month.html", dict(year=year, month=month, user=request.user,
                        month_days=lst, mname=mnames[month-1]))
Reply all
Reply to author
Forward
0 new messages