HowTo upload file to AppEngine using Django provided by Google (0.96)

16 views
Skip to first unread message

Sharp-Developer.Net

unread,
Jun 22, 2008, 6:31:47 PM6/22/08
to Google App Engine
Hi,

Could anyone give me a sample how to upload file using Django provided
by Google AppEngine?

I have a very simple form:

class ImageUploadForm(forms.Form):
file = forms.Field(widget=forms.FileInput())

when I upload file the form is invalid and next code is throwing error
"file"
==
if request.method == "POST":
imageForm =
my_forms.ImageUploadForm(request.POST,request.FILES)
if not imageForm.is_valid():
raise Exception("; ".join(imageForm.errors))
==

The form is coded as:

==
<form method="post" enctype="multipart/form-data" action="">
==

I tryed to access clean_data or cleaned_data or data or file property
- no luck. (yes - I'm newbie to Python :(

I've searched for last 30 minutes and have not found any examples or
snippets.

I believe a lot of people would apreciate if someone share a workign
sample code.

Thanks in advance,
--
Alexander Trakhimenok
http://sharp-developer.net/

Mattias Johansson

unread,
Jun 22, 2008, 7:22:14 PM6/22/08
to Google App Engine
Can't help you there, I'm afraid.
Can I suggest upgrading to 0.97 and using the Django Helper? The
general recommendation seems to be to use Django 0.97 instead of
sticking with the google-provided one.

/Mattias
http://appengineguy.com

On 23 Juni, 00:31, "Sharp-Developer.Net"

Sharp-Developer.Net

unread,
Jun 23, 2008, 5:55:41 AM6/23/08
to Google App Engine
Is there a Djnago distr with < 1000 files?

I'm curios everyone need to figure out himself what should be included/
excluded :(.

I think there should be a way to do it with Django provided by Google
otherwise it's a bug that should be logged.

What do you think?
--
Alexander Trakhimenok
http://sharp-developer.net

On Jun 23, 12:22 am, Mattias Johansson <mattias.johans...@gmail.com>
wrote:
> Can't help you there, I'm afraid.
> Can I suggest upgrading to 0.97 and using the Django Helper? The
> general recommendation seems to be to use Django 0.97 instead of
> sticking with the google-provided one.
>
> /Mattiashttp://appengineguy.com
> > Alexander Trakhimenokhttp://sharp-developer.net/- Hide quoted text -
>
> - Show quoted text -

nchauvat (Logilab)

unread,
Jun 23, 2008, 6:31:44 AM6/23/08
to Google App Engine
> What do you think?

http://www.logilab.org/blog/5216 is my opinion. In one sentence:
Google is providing AppEngine, and Django-on-appengine is a demo of
how to use AppEngine, not the One True Framework.

teem

unread,
Jun 25, 2008, 1:47:50 AM6/25/08
to Google App Engine
Hi,

I've rolled out a simple file storage gae and django. It's in
http://teemlabs.timmedina.com/files/

This is how I did it:

In the view:
for f, file_info in request.FILES.items():
fu = FileUpload(filename=file_info['filename'],
content_type=file_info['content-type'],
content=db.Blob(file_info['content']),
owner=users.get_current_user())
fu.put()

The model looks like this:

class FileUpload(db.Model):
owner = db.UserProperty()
filename = db.StringProperty()
content_type = db.StringProperty()
content = db.BlobProperty()
date_added = db.DateProperty(auto_now_add=True)

I didn't use forms though, LOL

Check out http://www.djangoproject.com/documentation/0.96/request_response/
for details on the request.FILES.

Hope this helps.

teem
http://www.timmedina.com/

Ryan

unread,
Jun 25, 2008, 2:34:25 AM6/25/08
to Google App Engine
Could anybody provide me with the links to download django 0.97

Mattias Johansson

unread,
Jun 25, 2008, 3:28:36 AM6/25/08
to Google App Engine
0.97 is not actually released, but under development, which means it
in a Subversion repository, and under constant change. You can very
easily check out the latest build by using TortoiseSVN. How to do this
will be my blog entry of the day - stay tuned.

/Mattias, an App Engine Guy
http://appengineguy.com

Mattias Johansson

unread,
Jun 25, 2008, 3:30:52 AM6/25/08
to Google App Engine
By the way, blatant plug for an entry on my blog:

Uploading files to App Engine via Django ModelForms
http://appengineguy.com/2008/06/uploading-files-to-app-engine-via.html

Needs 0.97, though, but you really SHOULD use it - don't stick with
the old django version.

/mattias


On 25 Juni, 08:34, Ryan <cher...@ensarm.com> wrote:

Ryan

unread,
Jun 25, 2008, 3:34:28 AM6/25/08
to Google App Engine
hi guys,
I did manage to get hold of a copy of the 0.97 installer. I
have downloaded the app engine helper for django project which
contains appengine_django folder which contains the helper files.

I am working on Windows XP.

When I first tried to run the application I got the error that the
google app engine was not found. I then had to copy the appengine sdk
folder to the application folder and then the app started working. I
had a question related to this. So while uploading the application
would the google app engine sdk folder be uploaded too??
I keep getting these warnings
WARNING:root:Loading the SDK from the 'google_appengine' subdirectory
is now deprecated!
WARNING:root:Please move the SDK to a subdirectory named
'.google_appengine' instead.


I also get an error when i try to run this command
python manage.py update
The error is as follows
Error: Your action, 'update', was invalid.

I was wondering whether I am missing something

regards,
Cherian

Mattias Johansson

unread,
Jun 25, 2008, 2:16:36 PM6/25/08
to Google App Engine
Hey Cherian

I have now posted a guide on how to Check out the latest version of
Django using tortoisesvn:
http://appengineguy.com/2008/06/how-to-check-out-latest-version-of.html

I have also included a couple of pointers on getting the Django Helper
r30 running - read them, since they solve your issues.

/Mattias, an App Engine Guy
http://appengineguy.com


Ryan

unread,
Jun 26, 2008, 5:00:11 AM6/26/08
to Google App Engine
hey thanks mathias for taking the effort to put up the post.

The warnings have disappeared and I no longer have to put the SDK
folder inside the app engine folder.

But this Error: Your action, 'update', was invalid. still remains when
i try to run this command python manage.py update
I dont see any action called update when I type in
python manage.py --help

One more thing.When I try to print the version of django

from django.http import HttpResponse
from django import VERSION
def current_version(request):
html = "<html><body>It is now %s.</body></html>" % str(VERSION)
return HttpResponse(html)
It shows me
"It is now (0, 96.099999999999994, None)".

But when I go to the python prompt and do this
>>> import django
>>> django.VERSION

This is what is displayed
(0, 97, 'pre')

Im a little confused because of this.

Regards,
Cherry
Reply all
Reply to author
Forward
0 new messages