You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def get_filters(self):
# return the filters to be used in the report
# Note: the use of Q filters and kwargs filters
filters = {}
q_filters = []
if self.cleaned_data["secure"] == "secure":
filters["is_secure"] = True
elif self.cleaned_data["secure"] == "non-secure":
filters["is_secure"] = False
if self.cleaned_data["method"]:
filters["method"] = self.cleaned_data["method"]
if self.cleaned_data["response"]:
filters["response"] = self.cleaned_data["response"]
if self.cleaned_data["other_people_only"]:
q_filters.append(~Q(user=self.request.user))
Hello, Thank you for this.
Yes the documentation is missing that
the form is accepting the request on its init, and attaching it to self
How the view sends the request to the form
classMyReport(ReportView):
# .... defget_form_kwargs(self):
kwargs=super().get_form_kwargs()
kwargs["request"] =self.request# send the request as a form kwarg, as you'd do in any CBVreturnkwargsclassRequestLogForm(BaseReportForm, forms.Form):
# ... def__init__(self, request, *args, **kwargs):
# special init signature to accept the request and attach itself.request=request# ....
In the documentation it seems you managed to refer to self.request.user when creating customs filters.
https://django-slick-reporting.readthedocs.io/en/latest/topics/filter_form.html
However when I do it, I get an error :
The error is : AttributeError: 'ManagerForm' object has no attribute 'request'
The text was updated successfully, but these errors were encountered: