Confused about uploading files (Cannot force both insert and updating in model saving)

2011-06-05 Thread Roy Smith
I'm trying to figure out how to upload a file. I've got a model that looks like: class DataSet(models.Model): file = models.FileField(upload_to='data/%Y/%m/%d') and my view method is: def create_data_set(request): if request.method == 'POST': form = DataSetForm(request.POST,

Re: Confused about uploading files (Cannot force both insert and updating in model saving)

2011-06-05 Thread Kenneth Gonsalves
On Sun, 2011-06-05 at 19:18 -0700, Roy Smith wrote: > ctx = {'form': form} > ctx.update(csrf(request)) indent these two lines -- regards KG http://lawgon.livejournal.com Coimbatore LUG rox http://ilugcbe.techstud.org/ -- You received this message because you are subscribed to the Googl

Re: Confused about uploading files (Cannot force both insert and updating in model saving)

2011-06-06 Thread Michal Petrucha
On Sun, Jun 05, 2011 at 07:18:24PM -0700, Roy Smith wrote: > I'm trying to figure out how to upload a file. I've got a model that > looks like: > > class DataSet(models.Model): > file = models.FileField(upload_to='data/%Y/%m/%d') > > and my view method is: > > def create_data_set(request):

Re: Confused about uploading files (Cannot force both insert and updating in model saving)

2011-06-06 Thread Roy Smith
> >    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]