FAQ
Working with Django 1.3

I can create and run an inline formset without problems using Approach 1.
However, when I try Approach 2, then I get the error below, triggered by
the line shown.

TypeError at /uploads/details/1
__init__() got an unexpected keyword argument 'instance'

Clearly, my syntax is wrong somewhere, but how do I go about fixing this?

Thanks
Derek


Approach No.1 - NO validation

# view file

UploadFieldFormSet = inlineformset_factory(Upload, UploadField,
max_num=None,
extra=9, can_delete=False)
if request.method == 'POST':
...
else:
formset = UploadFieldFormSet(instance=upload)


Approach No. 2 - Form validation

# form file

class UploadFieldFormSet(BaseFormSet):

def clean(self):
if any(self.errors):
return
# need to add special checks here...

# view file

UploadFieldFormSetFactory = inlineformset_factory(Upload, UploadField,

formset=UploadFieldFormSet,
max_num=None,
extra=9,
can_delete=False)
if request.method == 'POST':
...
else:
formset = UploadFieldFormSetFactory(instance=upload) # returns
error

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdjango-users @
categoriesdjango, python
postedApr 18, '12 at 7:24a
activeApr 18, '12 at 7:24a
posts1
users1
websitedjangoproject.com

1 user in discussion

Derek: 1 post

People

Translate

site design / logo © 2022 Grokbase