Re: AttributeError 'QuerySet' object has no attribute '_meta'

2019-08-18 Thread Kean Dumba
Ok thanks is there a way to call all objects, as this is more user friendly
and efficient when potentially editing many object fields?

On Sun, 18 Aug 2019 at 18:05, Daniel Roseman  wrote:

> You can't pass *all* the objects to the form. You have to get the specific
> one you want to edit and pass that as the instance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e78cfd54-9800-4c17-b8a4-0ffaf5ddcfd4%40googlegroups.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKvrVZO_rKiPOm9ZLZ%2BmiUpTgUy-xim%2Br7s8kRWskThHtndjpw%40mail.gmail.com.


AttributeError 'QuerySet' object has no attribute '_meta'

2019-08-18 Thread Daniel Roseman
You can't pass *all* the objects to the form. You have to get the specific one 
you want to edit and pass that as the instance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e78cfd54-9800-4c17-b8a4-0ffaf5ddcfd4%40googlegroups.com.


AttributeError 'QuerySet' object has no attribute '_meta'

2019-08-18 Thread Kean
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



-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5e4d57f1-e41b-4692-8814-1c1888e563dc%40googlegroups.com.