I get an error TypeError at /brand/5 get() missing 2 required positional arguments: 'self' and 'request'

Viewed 119

Everything worked well until I made a brand details page for my online store. I never encountered this error, and it looks like there is no solution availble for my case. I think its unique for every developer.

TypeError at /brand/5

get() missing 2 required positional arguments: 'self' and 'request'

Here is my code:

views.py

from django.shortcuts import render, get_object_or_404
from .models import Product,ProductCategory, Brand
# Create your views here.
from django.views import generic



class Brands(generic.ListView):

    model = Brand
    template_name = 'productcatalog/brands.html'

    def get_context_data(self, **kwargs):

        context = super(Brand, self).get_context_data(**kwargs)
        brands = Brand.objects.all()


        context['brands']=brands

        return context





class Brand(generic.DetailView):
    model = Brand 
    tempal_name = 'productcatalog/brand_details.html'

    def get_context_data(self, **kwargs):

        context = super(Brand, self).get_context_data(**kwargs)
        brand = get_object_or_404(Brand, id=self.kwargs['pk'])


        context['brand']=brand

        return context

models.py

class Brand(models.Model):
    name = models.CharField(max_length=300,blank=True)

    def __str__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('product_catalog')

Can anyone assist?

Thank you in advance!

0 Answers
Related