Ah! Okay.
Thank you!
On Thursday, January 2, 2020 at 11:08:53 AM UTC+13, Jason wrote:
>
> when you do
>
> return jobs, print(jobs)
>
>
>
> you're returning a tuple from the method, which is not what is expected.
> Remove the print statement from that line
>
>
> On Wednesday, January 1, 2020 at 5:02:13 PM UTC-5, Sam Hefer wrote:
>>
>> Hi,
>>
>> I'm having some issues with displaying a filtered list in a template.
>>
>> My View:
>>
>> class MyJobs(ListView):
>> model = Job
>> template_name = 'jobs/my_job_list.html'
>> context_object_name = 'jobs'
>>
>> def get_queryset(self, *args, **kwargs):
>> jobs = Job.objects.filter(company_name__owner=self.request.user)
>> return jobs, print(jobs)
>>
>>
>> My Template:
>>
>> <ul>
>> {% for job in jobs %}
>> <li>{{ job.company_name }}</li>
>> {% endfor %}
>> </ul>
>>
>>
>> The print function on jobs shows the correct list for the logged in user,
>> but for some reason, in the template the view only lists two objects (for
>> all users) and the field reference doesn't show anything (jobs.company_name
>> is always empty).
>>
>> Have I missed something?
>>
>> Thanks,
>> Sam
>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/4dc7cd6a-9e34-4d37-b319-9c808d265c7f%40googlegroups.com.