Hi.
I have two views for two different templates. The first view takes to args
request
and project_id
and returns the context of some logic based around the project_id
def show_project_details(request,project_id):
The second view is more generic
def dashboard_view(request):
Both views render different templates
return render(request, 'pages/project_details.html', {"project": project,
return render(request, "dashboard.html", {"project_list": project_list,
On the dashboard view, i have a table that shows a list of projects using {% for project in project_list %}
within this table i also want to show specific data of each project. But to return then data i need to pass in the project_id
as part of the request but canât set that within the def dashboard_view(request):
as its not used to render the page, but only needed when returning the specific project data.
This is the logic within the first view
if Response2.objects.filter(project_name_id=project_id, questionnaire_id = 4).exists():
evaluation_response = Response2.objects.get(project_name_id=project_id, questionnaire_id = 4)
evaluation_positiveplus = Answer2.objects.filter(answer = "++", response=evaluation_response).count()
evaluation_positive = Answer2.objects.filter(answer = "+", response=evaluation_response).count()
evaluation_neutral = Answer2.objects.filter(answer = "0", response=evaluation_response).count()
evaluation_negative = Answer2.objects.filter(answer = "-", response=evaluation_response).count()
evaluation_doublenegative = Answer2.objects.filter(answer = "--", response=evaluation_response).count()
evaluation_null = Answer2.objects.filter(answer = "" , response=evaluation_response).count()
evaluation_total = ((evaluation_positiveplus * 2) + (evaluation_positive)) - ((evaluation_doublenegative * 2) - (evaluation_negative))
else:
evaluation_response = "null"
evaluation_positiveplus = "null"
evaluation_positive = "null"
evaluation_neutral = "null"
evaluation_negative = "null"
evaluation_doublenegative = "null"
evaluation_null = "all"
evaluation_total = "null"
I need to return the evaluation_total
on the first view, if i add this logic to the second view then where do i get/pass in the project_id
without adding to the def dashboard_view(request):
or can i pass the data between the first and second view somehow?
Hope this makes sense.
Tom.