1

views.py:

def cal_main(request, year=None):
if year: year = int(year)
else:    year = time.localtime()[0]

nowy, nowm = time.localtime()[:2]
lst = []

# create a list of months for each year, indicating ones that contain entries and current

for y in [year, year+1, year+2]:
    mlst = []
    for n, month in enumerate(mnames):
        entry = current = False   # are there Entry(s) for this month; current month?
        entries = Entry.objects.filter(date__year=y, date__month=n+1)
        if y == nowy and n+1 == nowm:
            current = True

        if entries:
            entry = True
        mlst.append(dict(n=n+1, name=month, entry=entry, current=current))
    lst.append((y, mlst))

return render_to_response("calend.html", dict(years=lst, user=request.user, year=year,reminders=reminders(request)))

urls.py:

url(r'^(\d+)/$', 'cal_main'),
url(r'^calendar/$','cal_main'),  

calend.html:

"{% url 'views.cal_main' year|add:'1' %}"    

I would like to display current and the next year but I get an error:

NoReverseMatch Reverse for "views.cal_main" with arguments "(2015,)" and keyword arguments '{}' not found. 0 pattern(s) tried: []

I've already looked for some tips how to deal with this and I feel like I tried everything but there is the same error whole the time. I've never used django before so after trying what people write on the internet I don't know what else I can try so I will be greatful if someone could help me.

I'm using django 1.7 and python 2.7.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Meii
  • 33
  • 7

1 Answers1

0

Pass the url name in the url template tag:

"{% url 'cal_main' year|add:'1' %}" 
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195