Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
关于django日历错误_Django - Fatal编程技术网

关于django日历错误

关于django日历错误,django,Django,我有一些错误:我该怎么做?为什么我不能导入日历? 我正在使用导入日历。对吗? 这就是错误: 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://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.
这是my 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]))
这是URL.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"),

将URL.py更改为以下代码。你也应该仔细阅读


URL.py文件中不能有最后一行,因为它引用的是view article.views.month,它至少需要两个参数month和year,而该URL不会向其中传递任何参数。

与views.py文件在同一目录中是否有calendar.py?不,没有,我不知道calendar.py!!你的URL.py文件是什么样子的?好的,这是URL.py:urlr^month/\d+/\d+/prev | next/$,article.views.month,urlr^month/\d+/\d+/$,article.views.month,urlr^month/$,article.views.month,这是答案吗?如果是这样的话,你能这样标记吗?请将我的答案标记为你问题的答案。
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"),