Monday 15 April 2013

python - Using Django CBV's without overriding get_context_data -



python - Using Django CBV's without overriding get_context_data -

is there anyway can take advantage of django's default cbv's without resulting super calls on get_context_data send pieces of info.

for instance, have site cbv's handle 99% of work on own, i'd send minor bits of static info such page titles , seems unnecessary utilize get_context_data accomplish this.

i'm aware can following:

class page(detailview): model: mymodel template_name: 'something.html' title: 'some page title'

and reference title in template view.title. i'd page title attribute of model. i'm able through following:

get_context_data(self, **kwargs): context = super(page, self).get_context_data(**kwargs) context['title'] = 'page title | %s' % (self.get_object().title) homecoming context

is possible me reference individual model beingness called in detail view without running query or using get_context_data can model's title attribute , utilize access view.title in template?

i can't see reason define method title. whole point of detailview have access object in template, via {{ object }}. why not {{ object.title }}?

python django

No comments:

Post a Comment