Hi,

Is it possible to mark a FileField in my model as required

My model looks like :
class FileUpload(models.Model):
owner = models.CharField(max_length=200,blank=False, null=False)
record = models.FileField(upload_to=path_and_rename,blank=False, null=False)

1st statement :
According to what i have read the blank and null parameter are not necessary
and only the parameter "upload_to" and "storage" are availables

2nd statement : 
Secondly, it seems that the field validation are done at the form level or 
serializer level.

I would like to know if these 2 statements are true?

when I use python manage.py shell and make a test of creating a FileUpload 
object and save it, i dont get any error saying the that filefield is 
required :
## steps :
test = FileUpload(owner="test")
test.save()

## expected :
Error : filefield "record" is required!

## actual behavior :
save the object without error

Is it possible to put the filefield as required at the model level?
or
Do i have to make the validation of the field before/at an upper level?

Thank you
Cyril

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/98abe442-d602-4b17-9a80-4ea63402587dn%40googlegroups.com.

Reply via email to