On Tue, 2009-05-05 at 21:42 -0300, Gabriel wrote:
> djangomax escribió:
> > According to the Django Book for version 1.0, the following should
> > work:
> > 
> > fileField = forms.FileField(upload_to='foo')
> > 
> > However, I get an error saying there was an unexpected argument. Any
> > idea why?
> > I'm new to Django and may be doing something outright stupid.

There is a difference between model fields (which are in the
django.db.models.* namespace) and form fields (in the django.forms.*
namespace).

The models.FileField class takes an upload_to parameter. The
forms.FileField class does not. This is because form fields only
validate that the input is correct and turn it into an appropriate
Python object. They are not concerned with how to save things. Model
fields, on the other hand are all about persistent storage (i.e.
saving).


> > 
> > thx,
> > djangomax
> > 
> 
> upload_to should be a global function:

This isn't correct (for model fields; as noted above, for form fields,
upload_to doesn't make sense). A callable is a possible value to pass in
(and it doesn't have a be a global function -- any callable will do),
but a string is legal, too.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to