All:

I'm adding an app (from django snippits) that is just a template tag
for a calendar application in my blog. This is the new directory
structure:

/apps/postcal
              |
              ----------> __init__.py
              |
              ----------> /templatetags
                                        |
                                        ----------> __init__.py
                                        |
                                        ----------> calendar.py

settings.py has been modified to include postcal as such:

ADDITIONAL_APPS = (
    'recaptcha',
    'pingback',
    'watchlist',
    'blogroll',
    'robots',
    'django.contrib.admindocs',
    'gravatar',
    'userdata',
    'thumbnail',
    'postcal',
    )

Calls to manage.py that worked fine before, now throw the error:
"Error: no module named manager".

calendar.py is:

from datetime import date, timedelta
from django import template
from blog.models import Post

register = template.Library()

def get_last_day_of_month(year, month):
    if (month == 12):
        year += 1
        month = 1
    else:
        month += 1
    return date(year, month, 1) - timedelta(1)

def month_cal(year, month):
    post_list = Post.objects.filter(date__year=year,
date__month=month)

    first_day_of_month = date(year, month, 1)
    last_day_of_month = get_last_day_of_month(year, month)
    first_day_of_calendar = first_day_of_month - timedelta
(first_day_of_month.weekday())
    last_day_of_calendar = last_day_of_month + timedelta(7 -
last_day_of_month.weekday())

    month_cal = []
    week = []
    week_headers = []

    i = 0
    day = first_day_of_calendar
    while day <= last_day_of_calendar:
        if i < 7:
            week_headers.append(day)
        cal_day = {}
        cal_day['day'] = day
        cal_day['event'] = False
        for post in post_list:
            if day >= post.date.date() and day <= post.date.date():
                cal_day['event'] = True
        if day.month == month:
            cal_day['in_month'] = True
        else:
            cal_day['in_month'] = False
        week.append(cal_day)
        if day.weekday() == 6:
            month_cal.append(week)
            week = []
        i += 1
        day += timedelta(1)

    return {'calendar': month_cal, 'headers': week_headers}

register.inclusion_tag('templatetags/calendar.html')(month_cal)

Any suggestions??

Thanks!

-dls
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to