Re: Confused about uploading files (Cannot force both insert and updating in model saving)
> > if form.is_valid():
> > f = request.FILES['file']
> > data_set = DataSet()
> > data_set.save('foo', f)
>
> I suspect this is the problem: you create an empty instnce of DataSet
> and then call its save method. model.save has three optional arguments
> [1], in this case you call it with force_insert='foo', force_update=f.
>
> Both f and 'foo' evaluate to True, which is an obvious conflict.
Ah, yes, of course. I was mixing up model.save() and
model.FileField.save(). Thanks for setting me straight. What I
wanted was this:
if form.is_valid():
f = request.FILES['file']
data_set = DataSet(file=f)
data_set.save()
--
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home