mercredi 25 mars 2020

Python Django for loop error in Blog Categories

views.py

class PostDetail(DetailView):
template_name = "posts/single.html"
model = Post
context_object_name = "single"
def get_context_data(self, **kwargs):
    context = super(PostDetail, self).get_context_data(**kwargs)
    context['allCategories'] = Category.objects.all()

    return context

models.py

class PostDetail(DetailView):
template_name = "posts/single.html"
model = Post
context_object_name = "single"
def get_context_data(self, **kwargs):
    context = super(PostDetail, self).get_context_data(**kwargs)
    context['allCategories'] = Category.objects.all()

    return context

single.html

   <ul>
                           
                        </ul>
                    </div>

its have to work, but i can't see categories in my blog. And i dont take any warning. Please help..




Aucun commentaire:

Enregistrer un commentaire