我有一些错误:我该怎么办?,为什么我不能导入日历? 我正在使用导入日历。那是对的吗? 这是错误:
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)
Python Executable: /usr/bin/python
这是管理员错误:
Request Method: GET
Request URL: http://dev1.so2.co.jp/ihttest/ihttcs_test/admin/auth/user/
Django Version: 1.6.2
Exception Type: ViewDoesNotExist
Exception Value:
Could not import tcsarticle.views.calendar. View is not callable.
这是我的views.py:
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]
article = calendar.Calendar()
month_days = tcsarticle.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]))
这是urls.py:
url(r"^month/(\d+)/(\d+)/(prev|next)/$", "article.views.month"),
url(r"^month/(\d+)/(\d+)/$", "article.views.month"),
url(r"^month/$", "article.views.month"),
答案 0 :(得分:0)
将您的urls.py更改为以下代码。您还应该阅读captured url parameters。
url(r"^month/(?P<year>\d+)/(?P<month>\d+)/(prev|next)/$", "article.views.month"),
url(r"^month/(?P<year>\d+)/(?P<month>\d+)/$", "article.views.month"),
您的urls.py文件中不能包含最后一行,因为它引用了需要至少2个参数(月和年)的视图article.views.month
,而该网址将通过没有参数。