Answer the question
In order to leave comments, you need to log in
Mixin in Django?
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})
Answer the question
In order to leave comments, you need to log in
Have n't figured it out in three days ? You have two different views that receive two different slug
views that work with different models, but because of the mixin, get
they have the same method . Either don't use the mixin at all, as it's useless in your case, or make it generic so that it uses the model of the CBV it's mixed in with.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question