Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create view fails on a model with a File attribute #26

Open
jseutter opened this issue Oct 12, 2012 · 1 comment
Open

Create view fails on a model with a File attribute #26

jseutter opened this issue Oct 12, 2012 · 1 comment
Milestone

Comments

@jseutter
Copy link

Steps to recreate:

  1. Generate a scaffold where one of the model fields is a file type. Eg:
../venv/bin/python manage.py generatescaffold foo Foo name:char description:text screenshot:file
  1. python manage.py runserver
  2. Navigate to the Create View in the browser.
  3. Fill in the form, taking care to choose a file in the file picker.
  4. Click the Create button. The form displays a message above the file picker: "This field is required."

This was found in a clean virtualenv running Python 2.7, Django 1.4.1 and django-generate-scaffold 0.0.5.

@modocache
Copy link
Owner

The form needs to have enctype="multipart/form-data" specified, as detailed here: https://docs.djangoproject.com/en/dev/topics/http/file-uploads/?from=olddocs#basic-file-uploads

I will mark this as a new feature--namely, to determine whether a file field is included in the form and specify the necessary attributes dynamically. Alternatively, if that isn't feasible, to specify enctype="multipart/form-data" on all forms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants