python - Django Form is not visible in Inherited template -


i using template inheritance in django project. used form in base html page , submit button, when inherit base template template form disappeared submit button still there. have below templates.

base.html

<head>     {% load static staticfiles %}     <link rel="stylesheet" href="{% static "bootstrap.css" %}"> </script> </head> <body>      {% block option %}     <div class="row">     <div class="col-lg-3">         <form method = "post" action="">         {% csrf_token %}         {{form}}         <input type="submit" value="submit" />         </form>         </div>     </div>     {% endblock %}     <div class="row">         {% block content %}{% endblock %}     </div>  </body> 

chart.html

{% extends 'base.html' %} {% block content %} <head>     {% load static staticfiles %}     <link rel="stylesheet" href="{% static "bootstrap.css" %}">     <script type="text/javascript" src="https://www.google.com/jsapi"></script>     <script type="text/javascript">     google.load("visualization", "1", {packages:["corechart"]}); </script> </head>     <div id="container" align="center">         {{ column_chart.as_html }}  {% endblock %} 

how can make form visible there in chart html??

edit: added views

views.py

def select_chart_form(request):     form = selectchart(request.post)     if form.is_valid():         if (str(form.cleaned_data['status']) == '1'):             #print "hello naresh reverse('chart1')"             return httpresponseredirect('/chart1/')         if (str(form.cleaned_data['status']) == '2'):             return httpresponseredirect('/chart2/')     context = {                'form' : form                }     return render(request, 'base.html', context)  def video_by_user(request):     analysis = videodata.objects.annotate(watches_count = count('user')).order_by('-watches_count')[:10]     data_source = modeldatasource(analysis,fields=['video_name', 'watches_count'])     column_chart = gchart.columnchart(data_source,options={'title': "top 10 videos watched no. of users"})     context = {                 "data_source": data_source,                 "column_chart": column_chart,                }     return render_to_response('chart.html', context) 

i calling video_by_user method..after click on submit button.

the select_chart_form , video_by_user views separate. first 1 renders base.html, , supplies form variable when so. second 1 renders chart.html, inherits base.html, supplies variables needed chart.html itself: doesn't provide form needed base.html. need supply in video_by_user.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -