Error processing form when loading in Appblue Blobstore

I am using @wkornewald django-nonrel and django-filetransfer in the Google App Engine.

I can upload files just fine, but only when the whole form is valid. If the form fails validation for any field, it explodes completely, and is not returned to the user to correct the changes.

error message:

INFO 2011-03-10 20:27:09,496 dev_appserver.py:535] Internal redirection to /admin/rr/member/add/ INFO 2011-03-10 20:27:09,662 dev_appserver_blobstore.py:328] Upload handler returned 200 ERROR 2011-03-10 20:27:09,662 dev_appserver_blobstore.py:341] Invalid upload handler response. Only 301, 302 and 303 statuses are permitted and it may not have a content body. INFO 2011-03-10 20:27:09,680 dev_appserver.py:3317] "POST /_ah/upload/ag5kbXJvbGxpbnJlbGljc3IcCxIVX19CbG9iVXBsb2FkU2Vzc2lvbl9fGIkBDA HTTP/1.1" 500 - 

I have a simple model that looks like this:

 class Member(PhotoMixin, models.Model): name = models.CharField(max_length=50) name2 = models.CharField(max_length=50, blank=True) member_since = models.DateField(blank=True, null=True) full_size_image = models.FileField(verbose_name="Photo", upload_to='members/') is_active = models.BooleanField(default=True) 

Is there a way I can handle this more gracefully? I feel it, probably because django-filetransfers wants you to submit the form to the blob download url, and that url doesn't know what to do with the failure. Should there be an intermediate step that handles most of the form and messages in the download URL, if and only if everything else is valid?

+2
python google-app-engine django django-forms django-nonrel
source share
1 answer

For blobstore api, you need to look at the download handler to return the redirect.

as stated above in the error log:

 Only 301, 302 and 303 statuses are permitted and it may not have a content body. 

To get around this, I changed the add_view and change_view ModelAdmin methods to return a redirect to form validation failure, but attached to the query string so that the input values ​​were not lost.

Then, when initializing the form in the GET request, I check the "failed_validation" in the request parameters to indicate to send the form data to the forms / forms in order to activate the validation.

The code is on the bitpack: https: //aaronmadison@bitbucket.org/aaronmadison/django-filetransfers .

Now you can load into blobstore and handle errors ... yay.

+2
source share

All Articles