DeferredAttribute object in form

461 views
Skip to first unread message

Kean

unread,
Aug 17, 2019, 1:58:34 PM8/17/19
to Django users
Hi,

New to Django, struggling at every point, but still learning.

I have created an edit form, however when I run the edit, the below response is returned to all object fields in the form, allbeit suffix varies.

<django.db.models.query_utils.DeferredAttribute object at 0x10d9d60d0>

Please see my views.py

def editbusiness(request):
data = Businessownercreate.objects.all()
if request.method == "POST":
form = Businessownercreate(request.POST, instance=Businessownercreate)
if form.is_valid():
form.save()
return redirect("accounts:editremovebusiness")
else:
form = forms.Businessownercreate(instance=Businessownercreate)
return render(request, 'editbusiness.html', { 'form':form })

Please advise if anyone has seen this issue, cause and resolution?

Best,

K


salimon jamiu olashile

unread,
Aug 17, 2019, 8:48:32 PM8/17/19
to django...@googlegroups.com
It seems the model & form class names are clashing. If you want use the same name, you can import each module as a whole.

Edited:

from . import models, forms

def editbusiness(request):
data = models.Businessownercreate.objects.all()
if request.method == "POST":
form = forms.Businessownercreate(request.POST, instance=Businessownercreate)

Kean

unread,
Aug 18, 2019, 10:42:02 AM8/18/19
to django...@googlegroups.com
Hi Salimon, 

Thank you for the code and help.
When I update to your code I get the following error in the browser

Exception Type:AttributeError
Exception Value:
'ModelFormOptions' object has no attribute 'concrete_fields'
Im not sure why 

my models.py

class Businessownercreate(models.Model):
Creator = models.CharField(max_length=20)
Micro_Small_Medium = models.CharField(max_length=6)
Business_Name = models.CharField(max_length=20)
Owner_Firstname = models.CharField(max_length=20)
Owner_Surname = models.CharField(max_length=20)
Companies_House_Number = models.CharField(max_length=8)
Address_Line_1 = models.CharField(max_length=30)
Address_Line_2 = models.CharField(max_length=30)
Town = models.CharField(max_length=20)
City = models.CharField(max_length=20)
County = models.CharField(max_length=20)
Postcode = models.CharField(max_length=10)
Email = models.EmailField(max_length=50)
Phone = models.CharField(max_length=15)
Mobile = models.CharField(max_length=15)
Created_date = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self(Creator)

Pls advise if this is an error with my model?

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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFhdOCNUFeHnuF409CZQ%2BL9dB-p-D6CU3s_sso%2BGsZhsOqX3cg%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages