P
P
P4YK2021-06-01 21:49:45
Django
P4YK, 2021-06-01 21:49:45

Error: Product() got an unexpected keyword argument 'poster'?

I don't understand why he complains about poster
views.py :

def product_create(request):
        if request.method == "POST":
                form = ProductForm(request.POST)
                if form.is_valid():
                        return_category = form.cleaned_data["category"]
                        return_name = form.cleaned_data["name"]
                        return_slug = form.cleaned_data["slug"]
                        return_image = form.cleaned_data["image"]
                        return_description = form.cleaned_data["description"]
                        return_price = form.cleaned_data["price"]
                        current_user = request.user
                        if return_image == "":  # checks if it is empty
                                return_image = "https://i.imgur.com/qldLMTx.png"
                        product = Product(category=return_category, name=return_name, slug=return_slug, image=return_image, description=return_description, price=return_price, poster = current_user)
                        product.save()
                        return HttpResponseRedirect(reverse("Products"))
                else:
                        return render(request, "catalog/product/create.html", {
                                        "form": form
                        })

        return render(request, "catalog/product/create.html", {
                "form": ProductForm()
        })

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Melnikov, 2021-06-01
@P4YK

And what do you have in the model poster?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question