Python/ Django- copying buttons from one HTML page to another -


i have taken on development of project management software has been written in python/ django- having not used python or django @ before...

there few buttons displayed on 1 of webpages useful display on page within application. can see these buttons defined in budget.html following code:

{% block page_options %}     <a class="button m-r-md" href="{% url 'costing:export_csv' budget.id %}">export excel</a>     <a class="button m-r-md" href="{% url 'costing:schedule_of_works_post_dep' budget.id %}" target="_blank">schedule of works</a>     <a class="button m-r-md" href="?pdf=1" target="_blank">pdf</a>     <input data-view-url="{% url 'costing:combined_budget' project.id %}?search=" type="text" id="item_search" placeholder="item search" /> {% endblock page_options %} 

the other page, want able use them- variations.html has following code in {%block page_options %} block:

{% block page_options %}     <button class="button modalbtn" name="variation">+ add variation</button>      <a class="button" href="{% url 'costing:add_omit_builder' project.id %}">+ add group</a>      <a class="button" id="scas" data-view-url="{% url 'costing:preview_scas' project.budget_overview.version.id %}" href="{% url 'costing:scas_2_variations' project.budget_overview.version.id %}">+ standard cost assumptions</a>      <!--erf(17/11/2016 @ 1700) add buttons export adds/ omits table excel -->   {% endblock page_options %} 

so tried copying , pasting code first page block in second page:

{% block page_options %}     <button class="button modalbtn" name="variation">+ add variation</button>      <a class="button" href="{% url 'costing:add_omit_builder' project.id %}">+ add group</a>      <a class="button" id="scas" data-view-url="{% url 'costing:preview_scas' project.budget_overview.version.id %}" href="{% url 'costing:scas_2_variations' project.budget_overview.version.id %}">+ standard cost assumptions</a>      <!--erf(17/11/2016 @ 1700) add buttons export adds/ omits table excel -->         <a class="button m-r-md" href="{% url 'costing:export_csv' budget.id %}">export excel</a> <a class="button m-r-md" href="{% url 'costing:schedule_of_works_post_dep' budget.id %}" target="_blank">schedule of works</a> <a class="button m-r-md" href="?pdf=1" target="_blank">pdf</a> <input data-view-url="{% url 'costing:combined_budget' project.id %}?search=" type="text" id="item_search" placeholder="item search" />   {% endblock page_options %} 

but when try viewing page in browser, error page says:

noreversematch @ /costing/5915/variations/

i'm not sure why i'm getting error... need reference of calls views i'm using in code i've copied in elsewhere in html file? both of html files in same app, share same models.py file- have thought both able use of models & views defined within app?

is case? if so, why getting error on variations page?

based on said suppose problem don't have "budget" value in context variable. think view using first template send "budget" in it's context. second view don't. why when try budget.id in second template error.

try modify context in view , add "budget" variable it.

def my_view(request, pk):     budget= get_object_or_404(budget, pk=pk)     return render(request, 'budget.html', {'budget': budget}) 

or if using class based view should override get_context_data method:

def get_context_data(self, **kwargs):     context = super().get_context_data(**kwargs)     context['budget'] = self.budget     return context 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -