model for uploading a file - not working??

19 views
Skip to first unread message

Krondaj

unread,
Jan 25, 2012, 10:54:55 AM1/25/12
to Django users
in my model i'm using:

from django.db import models, datetime, MEDIA_ROOT

class RrsForm(models.Model):
#....

upload_doc = models.FileField(upload_to 'documents')

I get this error when I run (before running syncdb):

python manage.py sql rrs

I get:

File "/home/chrissmith/Dcode/rrws/rrs/models.py", line 36
upload_doc = models.FileField(upload_to 'documents')

^
SyntaxError: invalid syntax

any idea's what's up?



Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Krondaj

unread,
Jan 25, 2012, 11:10:15 AM1/25/12
to Django users
trying to show where ^ goes: haviing problems:  i'm hoping this shows
it at the last quote mark:
> File "/home/chrissmith/Dcode/rrws/rrs/models.py", line 36
> upload_doc = models.FileField(upload_to 'documents')
>                                                                                                 ^.
>SyntaxError: invalid syntax




Idon't know why i'm getting this error, or what i'm doing wrong

Martin Tiršel

unread,
Jan 25, 2012, 11:10:18 AM1/25/12
to django...@googlegroups.com

As the error message says, it is invalid syntax, you forgot the equals
sign (upload_to='documents').

Martin

bruno desthuilliers

unread,
Jan 25, 2012, 11:12:17 AM1/25/12
to Django users
On Jan 25, 4:54 pm, Krondaj <c.d.smi...@gmail.com> wrote:
(snip)
> I get:
>
>   File "/home/chrissmith/Dcode/rrws/rrs/models.py", line 36
>     upload_doc = models.FileField(upload_to 'documents')
>
> ^
> SyntaxError: invalid syntax
>
> any idea's what's up?

Please re-read carefully the error message and the line it points to.
The error message says "SyntaxError: invalid syntax", which means your
code isn't valid python code. The cursor points to where the syntax
error happens, that is the whitespace between 'upload_to' and
"documents".

The valid syntax would be:

upload_doc = models.FileField(upload_to='documents')

I strongly suggest you take some time to learn Python - at least do
the official tutorial - if you hope to get anything done in Django.


Reply all
Reply to author
Forward
0 new messages