Django Template Tags in Views

前端 未结 4 1469
被撕碎了的回忆
被撕碎了的回忆 2020-12-29 12:47

Hi I need to refresh my custom template tag --right_side.py-- via Ajax. Is there a way to import the template tag in the view and return it as HttpResponse because I don\'t

4条回答
  •  失恋的感觉
    2020-12-29 13:16

    You could create a template just containing your templatetag and nothing else. Then you would have in right_side.html:

    {%load cems_templatetags%}
    {%right_side%}
    

    and in the view something like:

    if request.isAjax():
      return render_to_response('right_side.html',RequestContext(request))
    

提交回复
热议问题