Hola,

I'm confused about adding extra content to a class based Generic View. I've
read
the docs at
file:///home/datakid/src/django-docs/topics/class-based-views.html
and have written the code accordingly.

I have Person, Certificate, Job and Compensation objects. The last three
all
have an FK (or M2M) back to a (or some) Person(s).

My DetailView subclass (which I've put in views.py - is there a better or
more
correct place for it?)

class PersonDetailView(DetailView):
    context_object_name = "person"
    model = Person

    def get_context_data(self,**kwargs):
        #Call the base implementation first to get a context
        context = super(PersonDetailView, self).get_context_data(**kwargs)
        #Add in a querysets
        context['job_list'] = Vacancy.complete.all()
        context['certificate_list'] = Certificate.objects.all()
        context['claim_list'] = Compensation.objects.all()
        return context

But I don't want the full list of Vacancies, Certificates or Claims - I
just
want those that are linked to the person - how can I filter by these? I've
tried
.filter(self.get_id)
.filter(self.request.get_id)
.filter(self.person.get_id)
.filter(self.request.person.get_id)
.filter(applicants__get_id__exact=self.get_id) (in the case of Vacancy) etc

How do I filter by the person object that is already in the context?
I know the answer is simple - I should wait until tomorrow when my brain is
fresher, but I want to finish this off tonight if possible.

Of course, the other thing that I can't help but thinking is that at this
point, the non-generic-view method of urls/views might be a simpler way to
go. While Generic Views are quite versatile,  is there a point at which
they are considered to restricting?

L.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to