2006-05-02 09:31:56 +08:00
|
|
|
from django.template import loader, RequestContext
|
|
|
|
from django.core.exceptions import ObjectDoesNotExist
|
2005-07-13 09:25:57 +08:00
|
|
|
from django.core.xheaders import populate_xheaders
|
2006-08-22 01:40:54 +08:00
|
|
|
from django.db.models.fields import DateTimeField
|
2006-05-02 09:31:56 +08:00
|
|
|
from django.http import Http404, HttpResponse
|
2005-07-13 09:25:57 +08:00
|
|
|
import datetime, time
|
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
def archive_index(request, queryset, date_field, num_latest=15,
|
|
|
|
template_name=None, template_loader=loader,
|
2006-06-03 21:37:34 +08:00
|
|
|
extra_context=None, allow_empty=False, context_processors=None,
|
2006-07-28 00:36:02 +08:00
|
|
|
mimetype=None, allow_future=False):
|
2005-07-13 09:25:57 +08:00
|
|
|
"""
|
|
|
|
Generic top-level archive of date-based objects.
|
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
Templates: ``<app_label>/<model_name>_archive.html``
|
2005-07-13 09:25:57 +08:00
|
|
|
Context:
|
|
|
|
date_list
|
|
|
|
List of years
|
|
|
|
latest
|
|
|
|
Latest N (defaults to 15) objects by date
|
|
|
|
"""
|
2006-06-03 21:37:34 +08:00
|
|
|
if extra_context is None: extra_context = {}
|
2006-05-02 09:31:56 +08:00
|
|
|
model = queryset.model
|
2006-07-28 00:36:02 +08:00
|
|
|
if not allow_future:
|
|
|
|
queryset = queryset.filter(**{'%s__lte' % date_field: datetime.datetime.now()})
|
2006-05-02 09:31:56 +08:00
|
|
|
date_list = queryset.dates(date_field, 'year')[::-1]
|
2005-12-01 06:03:50 +08:00
|
|
|
if not date_list and not allow_empty:
|
2006-05-02 09:31:56 +08:00
|
|
|
raise Http404, "No %s available" % model._meta.verbose_name
|
2005-07-13 09:25:57 +08:00
|
|
|
|
2005-12-01 06:03:50 +08:00
|
|
|
if date_list and num_latest:
|
2006-05-02 09:31:56 +08:00
|
|
|
latest = queryset.order_by('-'+date_field)[:num_latest]
|
2005-07-13 09:25:57 +08:00
|
|
|
else:
|
|
|
|
latest = None
|
|
|
|
|
|
|
|
if not template_name:
|
2006-05-02 09:31:56 +08:00
|
|
|
template_name = "%s/%s_archive.html" % (model._meta.app_label, model._meta.object_name.lower())
|
2005-07-13 09:25:57 +08:00
|
|
|
t = template_loader.get_template(template_name)
|
2006-05-02 09:31:56 +08:00
|
|
|
c = RequestContext(request, {
|
2005-07-13 09:25:57 +08:00
|
|
|
'date_list' : date_list,
|
|
|
|
'latest' : latest,
|
2005-12-24 12:39:59 +08:00
|
|
|
}, context_processors)
|
2005-07-26 05:53:00 +08:00
|
|
|
for key, value in extra_context.items():
|
|
|
|
if callable(value):
|
|
|
|
c[key] = value()
|
2005-07-26 11:48:41 +08:00
|
|
|
else:
|
2005-07-26 05:53:00 +08:00
|
|
|
c[key] = value
|
2007-06-22 15:15:04 +08:00
|
|
|
return HttpResponse(t.render(c), mimetype=mimetype)
|
2005-07-13 09:25:57 +08:00
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
def archive_year(request, year, queryset, date_field, template_name=None,
|
2006-06-03 21:37:34 +08:00
|
|
|
template_loader=loader, extra_context=None, allow_empty=False,
|
2006-06-01 12:21:26 +08:00
|
|
|
context_processors=None, template_object_name='object', mimetype=None,
|
2006-07-28 00:36:02 +08:00
|
|
|
make_object_list=False, allow_future=False):
|
2005-07-13 09:25:57 +08:00
|
|
|
"""
|
|
|
|
Generic yearly archive view.
|
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
Templates: ``<app_label>/<model_name>_archive_year.html``
|
2005-07-13 09:25:57 +08:00
|
|
|
Context:
|
|
|
|
date_list
|
|
|
|
List of months in this year with objects
|
|
|
|
year
|
|
|
|
This year
|
2006-06-01 12:21:26 +08:00
|
|
|
object_list
|
|
|
|
List of objects published in the given month
|
|
|
|
(Only available if make_object_list argument is True)
|
2005-07-13 09:25:57 +08:00
|
|
|
"""
|
2006-06-03 21:37:34 +08:00
|
|
|
if extra_context is None: extra_context = {}
|
2006-05-02 09:31:56 +08:00
|
|
|
model = queryset.model
|
2005-07-13 09:25:57 +08:00
|
|
|
now = datetime.datetime.now()
|
2006-05-02 09:31:56 +08:00
|
|
|
|
2005-07-13 09:25:57 +08:00
|
|
|
lookup_kwargs = {'%s__year' % date_field: year}
|
2006-05-02 09:31:56 +08:00
|
|
|
|
2006-07-28 00:36:02 +08:00
|
|
|
# Only bother to check current date if the year isn't in the past and future objects aren't requested.
|
|
|
|
if int(year) >= now.year and not allow_future:
|
2005-07-13 09:25:57 +08:00
|
|
|
lookup_kwargs['%s__lte' % date_field] = now
|
2006-05-02 09:31:56 +08:00
|
|
|
date_list = queryset.filter(**lookup_kwargs).dates(date_field, 'month')
|
2006-02-19 04:13:46 +08:00
|
|
|
if not date_list and not allow_empty:
|
2005-07-13 09:25:57 +08:00
|
|
|
raise Http404
|
2006-06-01 12:21:26 +08:00
|
|
|
if make_object_list:
|
|
|
|
object_list = queryset.filter(**lookup_kwargs).order_by(date_field)
|
|
|
|
else:
|
|
|
|
object_list = []
|
2005-07-13 09:25:57 +08:00
|
|
|
if not template_name:
|
2006-05-02 09:31:56 +08:00
|
|
|
template_name = "%s/%s_archive_year.html" % (model._meta.app_label, model._meta.object_name.lower())
|
2005-07-13 09:25:57 +08:00
|
|
|
t = template_loader.get_template(template_name)
|
2006-05-02 09:31:56 +08:00
|
|
|
c = RequestContext(request, {
|
2005-07-13 09:25:57 +08:00
|
|
|
'date_list': date_list,
|
|
|
|
'year': year,
|
2006-06-01 12:21:26 +08:00
|
|
|
'%s_list' % template_object_name: object_list,
|
2005-12-24 12:39:59 +08:00
|
|
|
}, context_processors)
|
2005-07-26 05:53:00 +08:00
|
|
|
for key, value in extra_context.items():
|
|
|
|
if callable(value):
|
|
|
|
c[key] = value()
|
2005-07-26 11:48:41 +08:00
|
|
|
else:
|
2005-07-26 05:53:00 +08:00
|
|
|
c[key] = value
|
2007-06-22 15:15:04 +08:00
|
|
|
return HttpResponse(t.render(c), mimetype=mimetype)
|
2005-07-13 09:25:57 +08:00
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
def archive_month(request, year, month, queryset, date_field,
|
2005-12-24 12:39:59 +08:00
|
|
|
month_format='%b', template_name=None, template_loader=loader,
|
2006-06-03 21:37:34 +08:00
|
|
|
extra_context=None, allow_empty=False, context_processors=None,
|
2006-07-28 00:36:02 +08:00
|
|
|
template_object_name='object', mimetype=None, allow_future=False):
|
2005-07-13 09:25:57 +08:00
|
|
|
"""
|
|
|
|
Generic monthly archive view.
|
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
Templates: ``<app_label>/<model_name>_archive_month.html``
|
2005-07-13 09:25:57 +08:00
|
|
|
Context:
|
|
|
|
month:
|
2006-02-18 02:03:54 +08:00
|
|
|
(date) this month
|
|
|
|
next_month:
|
|
|
|
(date) the first day of the next month, or None if the next month is in the future
|
|
|
|
previous_month:
|
|
|
|
(date) the first day of the previous month
|
2005-07-13 09:25:57 +08:00
|
|
|
object_list:
|
|
|
|
list of objects published in the given month
|
|
|
|
"""
|
2006-06-03 21:37:34 +08:00
|
|
|
if extra_context is None: extra_context = {}
|
2005-07-26 11:48:41 +08:00
|
|
|
try:
|
|
|
|
date = datetime.date(*time.strptime(year+month, '%Y'+month_format)[:3])
|
|
|
|
except ValueError:
|
|
|
|
raise Http404
|
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
model = queryset.model
|
2005-07-13 09:25:57 +08:00
|
|
|
now = datetime.datetime.now()
|
2006-05-02 09:31:56 +08:00
|
|
|
|
2005-07-13 09:25:57 +08:00
|
|
|
# Calculate first and last day of month, for use in a date-range lookup.
|
|
|
|
first_day = date.replace(day=1)
|
2005-12-09 09:55:53 +08:00
|
|
|
if first_day.month == 12:
|
|
|
|
last_day = first_day.replace(year=first_day.year + 1, month=1)
|
|
|
|
else:
|
|
|
|
last_day = first_day.replace(month=first_day.month + 1)
|
2005-07-13 09:25:57 +08:00
|
|
|
lookup_kwargs = {'%s__range' % date_field: (first_day, last_day)}
|
2006-05-02 09:31:56 +08:00
|
|
|
|
2006-07-28 00:36:02 +08:00
|
|
|
# Only bother to check current date if the month isn't in the past and future objects are requested.
|
|
|
|
if last_day >= now.date() and not allow_future:
|
2005-07-13 09:25:57 +08:00
|
|
|
lookup_kwargs['%s__lte' % date_field] = now
|
2006-05-02 09:31:56 +08:00
|
|
|
object_list = queryset.filter(**lookup_kwargs)
|
2006-02-19 04:13:46 +08:00
|
|
|
if not object_list and not allow_empty:
|
2005-07-13 09:25:57 +08:00
|
|
|
raise Http404
|
2006-07-28 00:36:02 +08:00
|
|
|
|
|
|
|
# Calculate the next month, if applicable.
|
|
|
|
if allow_future:
|
|
|
|
next_month = last_day + datetime.timedelta(days=1)
|
|
|
|
elif last_day < datetime.date.today():
|
|
|
|
next_month = last_day + datetime.timedelta(days=1)
|
|
|
|
else:
|
|
|
|
next_month = None
|
|
|
|
|
2005-07-13 09:25:57 +08:00
|
|
|
if not template_name:
|
2006-05-02 09:31:56 +08:00
|
|
|
template_name = "%s/%s_archive_month.html" % (model._meta.app_label, model._meta.object_name.lower())
|
2005-07-13 09:25:57 +08:00
|
|
|
t = template_loader.get_template(template_name)
|
2006-05-02 09:31:56 +08:00
|
|
|
c = RequestContext(request, {
|
2006-03-01 11:37:57 +08:00
|
|
|
'%s_list' % template_object_name: object_list,
|
2005-07-13 09:25:57 +08:00
|
|
|
'month': date,
|
2006-07-28 00:36:02 +08:00
|
|
|
'next_month': next_month,
|
2006-02-18 02:03:54 +08:00
|
|
|
'previous_month': first_day - datetime.timedelta(days=1),
|
2005-12-24 12:39:59 +08:00
|
|
|
}, context_processors)
|
2005-07-26 05:53:00 +08:00
|
|
|
for key, value in extra_context.items():
|
|
|
|
if callable(value):
|
|
|
|
c[key] = value()
|
2005-07-26 11:48:41 +08:00
|
|
|
else:
|
2005-07-26 05:53:00 +08:00
|
|
|
c[key] = value
|
2007-06-22 15:15:04 +08:00
|
|
|
return HttpResponse(t.render(c), mimetype=mimetype)
|
2005-07-13 09:25:57 +08:00
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
def archive_week(request, year, week, queryset, date_field,
|
|
|
|
template_name=None, template_loader=loader,
|
2006-06-03 21:37:34 +08:00
|
|
|
extra_context=None, allow_empty=True, context_processors=None,
|
2006-07-28 00:36:02 +08:00
|
|
|
template_object_name='object', mimetype=None, allow_future=False):
|
2006-05-02 09:31:56 +08:00
|
|
|
"""
|
|
|
|
Generic weekly archive view.
|
|
|
|
|
|
|
|
Templates: ``<app_label>/<model_name>_archive_week.html``
|
|
|
|
Context:
|
|
|
|
week:
|
|
|
|
(date) this week
|
|
|
|
object_list:
|
|
|
|
list of objects published in the given week
|
|
|
|
"""
|
2006-06-03 21:37:34 +08:00
|
|
|
if extra_context is None: extra_context = {}
|
2006-05-02 09:31:56 +08:00
|
|
|
try:
|
|
|
|
date = datetime.date(*time.strptime(year+'-0-'+week, '%Y-%w-%U')[:3])
|
|
|
|
except ValueError:
|
|
|
|
raise Http404
|
|
|
|
|
|
|
|
model = queryset.model
|
|
|
|
now = datetime.datetime.now()
|
|
|
|
|
|
|
|
# Calculate first and last day of week, for use in a date-range lookup.
|
|
|
|
first_day = date
|
|
|
|
last_day = date + datetime.timedelta(days=7)
|
|
|
|
lookup_kwargs = {'%s__range' % date_field: (first_day, last_day)}
|
|
|
|
|
2006-07-28 00:36:02 +08:00
|
|
|
# Only bother to check current date if the week isn't in the past and future objects aren't requested.
|
|
|
|
if last_day >= now.date() and not allow_future:
|
2006-05-02 09:31:56 +08:00
|
|
|
lookup_kwargs['%s__lte' % date_field] = now
|
|
|
|
object_list = queryset.filter(**lookup_kwargs)
|
|
|
|
if not object_list and not allow_empty:
|
|
|
|
raise Http404
|
|
|
|
if not template_name:
|
|
|
|
template_name = "%s/%s_archive_week.html" % (model._meta.app_label, model._meta.object_name.lower())
|
|
|
|
t = template_loader.get_template(template_name)
|
|
|
|
c = RequestContext(request, {
|
|
|
|
'%s_list' % template_object_name: object_list,
|
|
|
|
'week': date,
|
|
|
|
})
|
|
|
|
for key, value in extra_context.items():
|
|
|
|
if callable(value):
|
|
|
|
c[key] = value()
|
|
|
|
else:
|
|
|
|
c[key] = value
|
2007-06-22 15:15:04 +08:00
|
|
|
return HttpResponse(t.render(c), mimetype=mimetype)
|
2006-05-02 09:31:56 +08:00
|
|
|
|
|
|
|
def archive_day(request, year, month, day, queryset, date_field,
|
2005-12-24 12:39:59 +08:00
|
|
|
month_format='%b', day_format='%d', template_name=None,
|
2006-06-03 21:37:34 +08:00
|
|
|
template_loader=loader, extra_context=None, allow_empty=False,
|
2006-05-31 23:08:06 +08:00
|
|
|
context_processors=None, template_object_name='object',
|
2006-07-28 00:36:02 +08:00
|
|
|
mimetype=None, allow_future=False):
|
2005-07-13 09:25:57 +08:00
|
|
|
"""
|
|
|
|
Generic daily archive view.
|
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
Templates: ``<app_label>/<model_name>_archive_day.html``
|
2005-07-13 09:25:57 +08:00
|
|
|
Context:
|
|
|
|
object_list:
|
|
|
|
list of objects published that day
|
|
|
|
day:
|
|
|
|
(datetime) the day
|
|
|
|
previous_day
|
|
|
|
(datetime) the previous day
|
|
|
|
next_day
|
|
|
|
(datetime) the next day, or None if the current day is today
|
|
|
|
"""
|
2006-06-03 21:37:34 +08:00
|
|
|
if extra_context is None: extra_context = {}
|
2005-07-26 11:48:41 +08:00
|
|
|
try:
|
|
|
|
date = datetime.date(*time.strptime(year+month+day, '%Y'+month_format+day_format)[:3])
|
|
|
|
except ValueError:
|
|
|
|
raise Http404
|
2005-07-26 06:07:04 +08:00
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
model = queryset.model
|
2005-07-13 09:25:57 +08:00
|
|
|
now = datetime.datetime.now()
|
2006-05-02 09:31:56 +08:00
|
|
|
|
2006-08-22 01:40:54 +08:00
|
|
|
if isinstance(model._meta.get_field(date_field), DateTimeField):
|
|
|
|
lookup_kwargs = {'%s__range' % date_field: (datetime.datetime.combine(date, datetime.time.min), datetime.datetime.combine(date, datetime.time.max))}
|
|
|
|
else:
|
|
|
|
lookup_kwargs = {date_field: date}
|
2006-05-02 09:31:56 +08:00
|
|
|
|
2006-07-28 00:36:02 +08:00
|
|
|
# Only bother to check current date if the date isn't in the past and future objects aren't requested.
|
|
|
|
if date >= now.date() and not allow_future:
|
2005-07-13 09:25:57 +08:00
|
|
|
lookup_kwargs['%s__lte' % date_field] = now
|
2006-05-02 09:31:56 +08:00
|
|
|
object_list = queryset.filter(**lookup_kwargs)
|
2005-07-13 09:25:57 +08:00
|
|
|
if not allow_empty and not object_list:
|
|
|
|
raise Http404
|
2006-07-28 00:36:02 +08:00
|
|
|
|
|
|
|
# Calculate the next day, if applicable.
|
|
|
|
if allow_future:
|
|
|
|
next_day = date + datetime.timedelta(days=1)
|
|
|
|
elif date < datetime.date.today():
|
|
|
|
next_day = date + datetime.timedelta(days=1)
|
|
|
|
else:
|
|
|
|
next_day = None
|
|
|
|
|
2005-07-13 09:25:57 +08:00
|
|
|
if not template_name:
|
2006-05-02 09:31:56 +08:00
|
|
|
template_name = "%s/%s_archive_day.html" % (model._meta.app_label, model._meta.object_name.lower())
|
2005-07-13 09:25:57 +08:00
|
|
|
t = template_loader.get_template(template_name)
|
2006-05-02 09:31:56 +08:00
|
|
|
c = RequestContext(request, {
|
2006-03-01 11:37:57 +08:00
|
|
|
'%s_list' % template_object_name: object_list,
|
2005-07-13 09:25:57 +08:00
|
|
|
'day': date,
|
|
|
|
'previous_day': date - datetime.timedelta(days=1),
|
2006-07-28 00:36:02 +08:00
|
|
|
'next_day': next_day,
|
2005-12-24 12:39:59 +08:00
|
|
|
}, context_processors)
|
2005-07-26 05:53:00 +08:00
|
|
|
for key, value in extra_context.items():
|
|
|
|
if callable(value):
|
|
|
|
c[key] = value()
|
2005-07-26 11:48:41 +08:00
|
|
|
else:
|
2005-07-26 05:53:00 +08:00
|
|
|
c[key] = value
|
2007-06-22 15:15:04 +08:00
|
|
|
return HttpResponse(t.render(c), mimetype=mimetype)
|
2005-07-13 09:25:57 +08:00
|
|
|
|
|
|
|
def archive_today(request, **kwargs):
|
|
|
|
"""
|
|
|
|
Generic daily archive view for today. Same as archive_day view.
|
|
|
|
"""
|
|
|
|
today = datetime.date.today()
|
|
|
|
kwargs.update({
|
|
|
|
'year': str(today.year),
|
|
|
|
'month': today.strftime('%b').lower(),
|
|
|
|
'day': str(today.day),
|
|
|
|
})
|
|
|
|
return archive_day(request, **kwargs)
|
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
def object_detail(request, year, month, day, queryset, date_field,
|
2005-12-24 12:39:59 +08:00
|
|
|
month_format='%b', day_format='%d', object_id=None, slug=None,
|
|
|
|
slug_field=None, template_name=None, template_name_field=None,
|
2006-06-03 21:37:34 +08:00
|
|
|
template_loader=loader, extra_context=None, context_processors=None,
|
2006-07-28 00:36:02 +08:00
|
|
|
template_object_name='object', mimetype=None, allow_future=False):
|
2005-07-13 09:25:57 +08:00
|
|
|
"""
|
|
|
|
Generic detail view from year/month/day/slug or year/month/day/id structure.
|
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
Templates: ``<app_label>/<model_name>_detail.html``
|
2005-07-13 09:25:57 +08:00
|
|
|
Context:
|
|
|
|
object:
|
|
|
|
the object to be detailed
|
|
|
|
"""
|
2006-06-03 21:37:34 +08:00
|
|
|
if extra_context is None: extra_context = {}
|
2005-07-26 11:48:41 +08:00
|
|
|
try:
|
|
|
|
date = datetime.date(*time.strptime(year+month+day, '%Y'+month_format+day_format)[:3])
|
|
|
|
except ValueError:
|
|
|
|
raise Http404
|
2005-07-26 06:07:04 +08:00
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
model = queryset.model
|
2005-07-13 09:25:57 +08:00
|
|
|
now = datetime.datetime.now()
|
2006-05-02 09:31:56 +08:00
|
|
|
|
2006-08-22 01:40:54 +08:00
|
|
|
if isinstance(model._meta.get_field(date_field), DateTimeField):
|
|
|
|
lookup_kwargs = {'%s__range' % date_field: (datetime.datetime.combine(date, datetime.time.min), datetime.datetime.combine(date, datetime.time.max))}
|
|
|
|
else:
|
|
|
|
lookup_kwargs = {date_field: date}
|
2006-05-02 09:31:56 +08:00
|
|
|
|
2006-07-28 00:36:02 +08:00
|
|
|
# Only bother to check current date if the date isn't in the past and future objects aren't requested.
|
|
|
|
if date >= now.date() and not allow_future:
|
2005-07-13 09:25:57 +08:00
|
|
|
lookup_kwargs['%s__lte' % date_field] = now
|
|
|
|
if object_id:
|
2006-05-02 09:31:56 +08:00
|
|
|
lookup_kwargs['%s__exact' % model._meta.pk.name] = object_id
|
2005-07-13 09:25:57 +08:00
|
|
|
elif slug and slug_field:
|
|
|
|
lookup_kwargs['%s__exact' % slug_field] = slug
|
|
|
|
else:
|
2006-05-02 09:31:56 +08:00
|
|
|
raise AttributeError, "Generic detail view must be called with either an object_id or a slug/slugfield"
|
2005-07-13 09:25:57 +08:00
|
|
|
try:
|
2006-05-02 09:31:56 +08:00
|
|
|
obj = queryset.get(**lookup_kwargs)
|
2005-07-13 09:25:57 +08:00
|
|
|
except ObjectDoesNotExist:
|
2006-05-02 09:31:56 +08:00
|
|
|
raise Http404, "No %s found for" % model._meta.verbose_name
|
2005-07-13 09:25:57 +08:00
|
|
|
if not template_name:
|
2006-05-02 09:31:56 +08:00
|
|
|
template_name = "%s/%s_detail.html" % (model._meta.app_label, model._meta.object_name.lower())
|
2005-07-25 06:21:09 +08:00
|
|
|
if template_name_field:
|
2006-05-02 09:31:56 +08:00
|
|
|
template_name_list = [getattr(obj, template_name_field), template_name]
|
2005-07-25 06:21:09 +08:00
|
|
|
t = template_loader.select_template(template_name_list)
|
|
|
|
else:
|
|
|
|
t = template_loader.get_template(template_name)
|
2006-05-02 09:31:56 +08:00
|
|
|
c = RequestContext(request, {
|
|
|
|
template_object_name: obj,
|
2005-12-24 12:39:59 +08:00
|
|
|
}, context_processors)
|
2005-07-26 05:53:00 +08:00
|
|
|
for key, value in extra_context.items():
|
|
|
|
if callable(value):
|
|
|
|
c[key] = value()
|
2005-07-26 11:48:41 +08:00
|
|
|
else:
|
2005-07-26 05:53:00 +08:00
|
|
|
c[key] = value
|
2007-06-22 15:15:04 +08:00
|
|
|
response = HttpResponse(t.render(c), mimetype=mimetype)
|
2006-05-02 09:31:56 +08:00
|
|
|
populate_xheaders(request, response, model, getattr(obj, obj._meta.pk.name))
|
2005-07-13 09:25:57 +08:00
|
|
|
return response
|