Hi,
New to Django but trying to stick with it.
I have created a model form, which creates ok.
I am trying to edit records. I have the following, but keep getting the QuerySet object has no attribute '_meta' in the browser.
my views.py
def editbusiness(request):
data = models.Businessownercreate.objects.all()
if request.method == "POST":
form = forms.Businessownercreate(request.POST, instance=data)
if form.is_valid():
form.save()
return redirect("accounts:editremovebusiness")
else:
form = forms.Businessownercreate(instance=data)
return render(request, 'editbusiness.html', context={ 'form':form })
my forms.py
class Businessownercreate(forms.ModelForm):
class Meta:
model = Businessownercreate
fields = [ "Creator", "Micro_Small_Medium", "Business_Name", "Owner_Firstname",
"Owner_Surname", "Companies_House_Number", "Address_Line_1", "Address_Line_2",
"Town", "City", "County", "Postcode", "Email", "Phone", "Mobile" ]
I'm have defined the meta, so i can't see why the query cant return the objects from the model to the form in this instance.
Please can anyone advise or help?
Best,
K