c.po...@bangor.ac.uk
unread,Sep 10, 2008, 4:50:29 AM9/10/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hi
I'm having a problem with inline formsets containing file field, i've
had a good google but couldn't find an answer, so apolgies if this is
a stupid or repetative question.
I have a model Applicatant, which has a one to many relation with
Education which contains a filefeild. My problem is that when django
comes to validate the inline form education it reports that the field
is empty, if i tell the model to allow empty feilds then the file is
not saved
Is it possible to use file fields with the inlineformset_factory or do
i need to go at this another way?
I have included my code, pretty simple and pretty much copied from the
documentation:
def myview(request):
InlineFormSet = inlineformset_factory(Applicant, Education)
applicant = Applicant.objects.get(pk=1)
if request.method == 'POST':
formset = InlineFormSet(request.POST, request.FILES,
instance=applicant)
if formset.is_valid():
Do stuff
else:
formset = InlineFormSet(instance=applicant)
return render_to_response("mytemplate.html", { "formset":
formset,})
where mytemplate.html is simply
<form action="./do" method="POST">
{{ formset.management_form }}
<table>
{% for form in formset.forms %}
{{ form.as_ul }}
{% endfor %}
</table>
<input type="submit" name="next" value="Next">
</form>
Many than ks
Charlotte