I want to get parameter from template. But when I do it gives an error:
TypeError at /report/2000-01-01/2022-08-12/Investigations/ wrapper_func() missing 1 required positional argument: 'request'
It takes the parameters true but I think I can't pass them to the views. How can I do it?
views.py
class GroupingReportsPage(ReportsMixin, ListView):
model = ProcessType
def case_groups(date_1, date_2, process_group):
fieldname = 'case_type_value'
cases = Case.objects.filter(date_created__range=[date_1, date_2])
process_types = ProcessType.objects.filter(reporting_group__option=process_group)
report_group = {}
print('cases')
print('cases')
print(cases)
print(process_types)
return cases
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
print('sadasds')
self.case_groups()
context['query_trend'] = 'query_trend'
return context
urls.py
path('report/<str:date_1>/<str:date_2>/<str:process_group>/', report.GroupingReportsPage.as_view(), name='process_groups'),
template
<a href="{% url 'fdm:process_groups' date_1 date_2 index %}" style="color: black">
{{index}}
</a>
CodePudding user response:
I'm not sure but this is probably caused by missing self
parameter in custom method (which is not static).
Change this:
def case_groups(date_1, date_2, process_group):
To this:
@staticmethod
def case_groups(date_1, date_2, process_group):
CodePudding user response:
def get_context_data(self, request, **kwargs):
Try to change your function declaration to include request
parameter.