views:

1154

answers:

4

Hi guys, im need to use a calendar, im developing a website for house's rental, my first own web project, so, the idea is that the user select a initial date and finish date, in the same month o any months (form January until April por example), and in the view (template) of the house availability i want to show all months (12) and where is busy the house ill show the day's with some different color...

im searching for django calendar, im testing, but if somebody know about it, please give me a hand :)

Thanks :)

+2  A: 

Did you take a look at Django Schedule and Django SwingTime ?

Pierre-Jean Coudert
+3  A: 

Take a look at some of the calendar related exapmles here to see if they work for you:

Also, you might consider using Python's HTMLCalendar as discussed here:

ars
+1  A: 

Here it is an example of overiding HTMLCalendar to display a queryset.

class QuerysetCalendar(HTMLCalendar):

def __init__(self, queryset, field):
    self.field = field
    super(QuerysetCalendar, self).__init__()
    self.queryset_by_date = self.group_by_day(queryset)

def formatday(self, day, weekday):
    if day != 0:
        cssclass = self.cssclasses[weekday]
        if date.today() == date(self.year, self.month, day):
            cssclass += ' today'
        if day in self.queryset_by_date:
            cssclass += ' filled'
            body = ['<ul>']

            for item in self.queryset_by_date[day]:
                body.append('<li>')
                body.append('<a href="%s">' % item.get_absolute_url())
                body.append(esc(item))
                body.append('</a></li>')
            body.append('</ul>')
            return self.day_cell(cssclass, '%d %s' % (day, ''.join(body)))
        return self.day_cell(cssclass, day)
    return self.day_cell('noday', ' ')


def formatmonth(self, year, month):
    self.year, self.month = year, month
    return super(QuerysetCalendar, self).formatmonth(year, month)

def group_by_day(self, queryset):
    field = lambda item: getattr(item, self.field).day
    return dict(
        [(day, list(items)) for day, items in groupby(queryset, field)]
    )

def day_cell(self, cssclass, body):
    return '<td class="%s">%s</td>' % (cssclass, body)
yml
So where is this called from? Not the template because it cannot do python code. The view? Could be, but all this formatting seems a bad idea for the view. A custom templatetag you have?In any event, you should be clear how you think this should be used.
hughdbrown
A: 

Guys, thanks a lot :), ill test the best way :)

Asinox