Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Class-based Views Customizing Class-based Views Combine DetailView and DeleteView

Andres Osorio
Andres Osorio
43,021 Points

I Keep getting, "Didn't find the form"

Hi, I've been working on this challenge for a couple of hours now, but can't make it pass. Could someone guide me on how to implement the DeleteView form in the article_detail.html?

Thanks alot for your time.

Cheers

articles/views.py
from django.views import generic

from . import models


class ArticleList(generic.ListView):
    model = models.Article


class ArticleDetail(generic.DeleteView, generic.DetailView):
    model = models.Article
    template_name = "articles/article_detail.html"


class ArticleCreate(generic.CreateView):
    fields = ('title', 'body', 'author', 'published')
    model = models.Article


class ArticleUpdate(generic.UpdateView):
    fields = ('title', 'body', 'author', 'published')
    model = models.Article


class ArticleDelete(generic.DeleteView):
    model = models.Article


class ArticleSearch(generic.ListView):
    model = models.Article

    def get_queryset(self):
        qs = super().get_queryset()
        term = self.kwargs.get('term')
        if term:
            return qs.filter(body__icontains=term)
        return qs.none()
articles/templates/articles/article_detail.html
<h1>{{ article.title }}</h1>
<p>By: {{ article.author }}</p>

{{ article.body|linebreaks }}

<hr />
<h1>Detele {{ article.title }}?</h1>
<form action="" method="POST">
    {% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Delete" />
</form>

1 Answer

May be answer is too late but nevertheless...I don't see import reverse_lazy and success_url =reverse_lazy('article:detail') in your views.py