On Sat, 2007-12-22 at 15:33 +0530, Kenneth Gonsalves wrote:
> 
> On 22-Dec-07, at 1:16 PM, Malcolm Tredinnick wrote:
[...]
> > You should always be checking is_valid() before trying to save to  
> > avoid
> > this type of problem. Since, newpage.is_valid() will be false here,  
> > you
> > can print out the errors and see what's going wrong.
> 
> checked that - am getting an error list - 'photo' 'this field is  
> required'. Which silly because the field is filled in. I tried  
> ModelForms with other field types, and find the same error comes when  
> a required field is not filled in. Even running is_valid is of no  
> help, because, unlike in new forms, a negative value for is_valid  
> does not return the form with errors as it should.

Hold on, there's some confusion going on here. Firstly, ModelForms *is*
part of newforms. It uses standard newforms practices. Calling
is_valid() on a form class returns False if and only if you've either
forgotten to supply data or self.errors is not empty. So is_valid() is
intimately tied to self.errors.

>  Anyway, I changed  
> the code like this:
> 
> def addph(request):
>      if request.POST:
>          newpage =Ph(request.POST)

Here's the problem.. I should have spotted  it the first time. You need
to pass in any files as the second argument to the form.

        newpage = Ph(request.POST, request.FILES)
        
So the form is complaining about something valid: you weren't giving it
the file data. I think you'll find that everything should work once you
change this.

Regards,
Malcolm

-- 
Everything is _not_ based on faith... take my word for it. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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