Navigation in django

后端 未结 30 1388

I\'ve just done my first little webapp in django and I love it. I\'m about to start on converting an old production PHP site into django and as part its template, there is a

30条回答
  •  -上瘾入骨i
    2020-11-27 09:46

    I do it like this:

    Statistics
    

    and then all I have to do is in my view add {'active_tab': 'statistics'} to my context dictionary.

    If you are using RequestContext you can get current path in your template as:

    {{ request.path }}
    

    And in your view:

    from django.template import RequestContext
    
    def my_view(request):
        # do something awesome here
        return template.render(RequestContext(request, context_dict))
    

提交回复
热议问题