С какой стати я должен передать RequestContext во всех моих ответах?

CSS word-wrap:break-word;, протестировано в FireFox 3.6.3

5
задан Community 23 May 2017 в 09:57
поделиться

2 ответа

Ваше намерение имеет смысл, большую часть времени вам понадобится RequestContext , и лишь в редких случаях его можно безопасно опустить из соображений производительности. Решение простое, вместо render_to_response используйте ярлык direct_to_template :

from django.views.generic.simple import direct_to_template

def contact(request):
    # snip ...
    return direct_to_template(request, 'contact.html', { 'myvar' : myvar })

... или render_to декоратор из django-раздражает :

from annoying.decorators import render_to

@render_to('template.html')
def foo(request):          
    bar = Bar.object.all()  
    return {'bar': bar}     
16
ответ дан 18 December 2019 в 09:52
поделиться

You don't necessarily have to do anything to the markup of your navigation to give the current one a different style - there are declarative ways to do that using CSS.

See my answer here: Django: Is there a better way to bold the current page link for an example.

1
ответ дан 18 December 2019 в 09:52
поделиться
Другие вопросы по тегам:

Похожие вопросы: