I'm writing an app to allow users in a school to upload newsletters to our 
website, but I'm having problems using models.FileField in a generic view. 
I've set 

MEDIA_ROOT = '/data/school/media/'

and MEDIA_URL is also set to a valid location. I've checked and re-checked 
permissions on the directories: www-data (apache user) has full RWX 
permissions. The model:

class Newsletter(models.Model):
    issue_date        = models.DateField()
    issue_number      = models.IntegerField()
    table_of_contents = models.TextField(null=True, blank=True)
    pdf_file          = models.FileField(upload_to='newsletters', null=True, 
blank=True)

In urls.py:

    # Create newsletter detail
    (r'^new/$',
        CreateView.as_view(
            model=Newsletter,
            template_name='newsletter/edit.html',
        )),

If I set the pdf_file field so that a file is required, it fails every time 
with the error "This field is required", even though a file has been 
selected. If I set it to "null=True, blank=True" (as above) it takes no 
notice of the file I have selected in the "pdf_file" upload field.

I'm not sure if I've missed something obvious. Searching around turns up an 
old bug which gives the same problem but was fixed years ago.

Any suggestions would be appreciated, TIA.

--
Simon

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to