keflavich
keflavich

Reputation: 19195

Failure to save a file in django

This is essentially a duplicate of this post but the answer doesn't work for me.

I've tried this:

from django.core.files.storage import FileSystemStorage

fs = FileSystemStorage(location='/a/legitimate/path)

class UploadedFile(models.Model):
    title = models.CharField(max_length=50)
    file = models.FileField(storage=fs,upload_to='fits/')

class UploadFileForm(forms.ModelForm): 
    class Meta: 
        model = UploadedFile 
        fields = ('title', 'file') 

but in my view, when I do:

    form = UploadFileForm(request.POST,request.FILES)
    if form.is_valid(): 
        form.save()

I get the following error:

no such table: upload_uploadedfile

What am I doing wrong? I'm a total beginner to django and have found the documentation to be rather opaque, so I am probably doing something incredibly dumb.

Upvotes: 0

Views: 113

Answers (1)

wkl
wkl

Reputation: 79893

Did you do a django-admin.py syncdb after creating your UploadedFile model?

The alternative is to run python manage.py syncdb from your project folder.

Upvotes: 1

Related Questions