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 django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d5abe2b5-b8a0-429e-b497-f290288bc1ae%40googlegroups.com.
No comments:
Post a Comment