blob_info = self.get_uploads()[0]
data = AForm(data=self.request.POST)
entity = data.save(commit=False)
entity.put()
im = Image(reference=entity)
im.primary_image = blob_info.key()
im.put()
entity.put()
...
Dispatching to upload handling is a view class that renders
self.render_template("upload.html", {
'form': form,
'form_url': blobstore.create_upload_url('/fileupload'),Then I enabled the form page to also able to edit an item
if self.request.get('id'):
a = A.get_by_id(long(self.request.get('id')))
form = AForm(instance = a)
else:
form = AForm()
After that I too have issues with validation and preview where
BlobStore seems doable to fit in a form.My form class is
class AForm(djangoforms.ModelForm):
text =
forms.CharField(widget=forms.Textarea(attrs={'rows':'11','cols':'70','class':'foo'}),label=_("content").capitalize())
class Meta:
model = A
fields = ['category','currency','price','title','phonenumber','postaladress','name','text','email']
#change the orderI now hope we can recommend or comment how to enable validation and preview the "official" way. Since django.contrib.formtools.preview appears built in GAE it could be good to first try what the SDK provides to minimize thirdparty library dependency. I didn't look at formish yet and will do so onwards.
1 comment:
INSERT
Post a Comment