django - How do i display inlines with DetailView? -



django - How do i display inlines with DetailView? -

i have project model. model has days inlines.

how display them using detailview?

my views.py looks this:

class projectdetailview(detailview): queryset = project.objects.all() slug_field = 'slug' template_name = 'projects/detail_project.html'

how pull through day inlines this?

i've tried:

def get_context_data(self, **kwargs): context = super(projectdetailview, self).get_context_data(**kwargs) project = project.objects.filter(slug=self.slug_field) context['days'] = day.objects.filter(project=project) homecoming context

but doesn't work. seems pointless i'm using generic view doing get_object_or_404 anyway pull days out.

how do properly?

there's no such thing inline model. there inline forms, forms model has foreignkey relationship parent model - don't seem talking forms.

in case, there's no need in code. can refer related models straight in template:

{% day in object.day_set.all %} {{ day.whatever }} {% endfor %}

django django-generic-views django-class-based-views

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -