Hello,
I'm trying to use ModelForm to create a form based on one of my
models. However, I'm getting the following error:
///
AttributeError at /plush/theone/
'ModelFormOptions' object has no attribute 'many_to_many'
///
Below is my code:
///
Views.py File
def theone(request):
a = TestForm()
if request.POST:
b = TestForm(data=request.POST, instance=a)
if b.is_valid():
b.save()
else:
assert False, "Errors"
else:
form = TestForm(instance=a)
return render_to_response('plush_mytest.htm', {'theform': form})
///
///
Models.py File
class MyTest(models.Model):
myfirst = models.CharField(max_length=100)
///
///
myform.py file
class TestForm(ModelForm):
class Meta:
model = MyTest
///
///
plush_mytest.htm File
<form method="POST" action="/plush/theone/" >
{{ theform.myfield }}
<input type="Submit" value="Submit" name="Submit" />
</form>
///
The error occurs when I get to the following line in my views.py file
'form = TestForm(instance=a)'.
Anybody have any suggestions?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---