Я обновляю свою модель, но она показывает мне эту ошибку:
У объекта 'ModelFormOptions' нет атрибута 'concrete_fields'
Какую ошибку я делаю?
views.py
class EditProduct(TemplateView):
template_name = 'stock/editproduct.html'
def get(self, request, product_id):
productedit = get_object_or_404(Product, pk=product_id)
data=Product.objects.get(id=product_id)
form = EditProductForm(instance=data)
args = {'form':form, 'productedit':productedit}
return render(request, self.template_name, args)
def post(self, request, product_id):
data = Product.objects.get(id=product_id)
form = EditProductForm(instance=data)
form = EditProductForm(request.POST, request.FILES, instance=form)
if form.is_valid():
productadded = form.save(commit=False)
productadded.saler = request.user
productadded.pub_date = timezone.datetime.now()
productadded.save()
return redirect('stock')
else:
args = {'form': form}
return render(request, self.template_name, args)
TRACEBACK
File "C:\Users\Adil Ijaz\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\Adil Ijaz\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\Adil Ijaz\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Adil Ijaz\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\auth\decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "C:\Users\Adil Ijaz\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\views\generic\base.py", line 71, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\Adil Ijaz\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\views\generic\base.py", line 97, in dispatch
return handler(request, *args, **kwargs)
File "C:\Users\Adil Ijaz\Desktop\onlineProject\market\stock\views.py", line 109, in post
form = EditProductForm(request.POST, request.FILES, instance=form)
File "C:\Users\Adil Ijaz\Desktop\onlineProject\market\stock\forms.py", line 39, in __init__
super(EditProductForm, self).__init__(*args, **kwargs)
File "C:\Users\Adil Ijaz\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\forms\models.py", line 293, in __init__
object_data = model_to_dict(instance, opts.fields, opts.exclude)
File "C:\Users\Adil Ijaz\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\forms\models.py", line 86, in model_to_dict
for f in chain(opts.concrete_fields, opts.private_fields, opts.many_to_many):
AttributeError: 'ModelFormOptions' object has no attribute 'concrete_fields'