B
B
BEKa T2019-04-07 16:32:07
Django
BEKa T, 2019-04-07 16:32:07

Fix the mixin?

When writing

from django.shortcuts import render
from django.shortcuts import get_object_or_404

from . models import *

class ObjectDetailMixin:
  model = None
  template = None

  def get(self, request, slug):
    obj = Tag.objects.get(slug__iexact=slug)
    return render(request, self.template, context={self.model.__name__.lower(): obj})

the page with only tags is displayed (obj = Tag.objects.get(slug__iexact=slug)) but
the page with posts does not
work
)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2019-04-07
@Bread09

You have a typo: the letter j is missing in the lineobj = Post.obects.get(slug__iexact=slug)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question