Re: what am I doing wrong?

2011-01-25 Thread Rob McQueen
Is there a reason why you inherit from forms.Form, but not forms.ModelForm ?
Is it successfully finding ModelForm without the reference to forms?

-Rob

On Tue, Jan 25, 2011 at 12:41 PM, MikeKJ  wrote:

>
> class CertForm(forms.Form):
>agree = forms.BooleanField(required=True, label="I confirm the above and
> agree.")
>cert = forms.BooleanField(required=False, label="I require a
> certificate")
>
> class UserAccountForm(ModelForm):
>class Meta:
>model = UserAccount
>
> class VideoAccountForm(ModelForm):
>class Meta:
>model = VideoAccount
>
> def certificate(request, id):
>if not request.user.is_authenticated():
>return HttpResponseRedirect('/user/login/')
>person = request.user
>check = UserProfile.objects.get(username=person)
>if check.approved_member and check.gp:
>part_vid = Part.objects.get(pk = id)
>cost = round((part_vid.runtime/60)*10,2)
>if request.POST:
>form = CertForm(request.POST)
>userform = UserAccountForm()
>videoform = VideoAccountForm()
>if form.is_valid():
>//normal form.cleaned_data stuff
>// userform
> data = {'user_id': 'check.id',
>'user_name': 'check.name',
>'user_email': 'check.email',
>'video_id': 'part_vid.id',
>'video_name': 'part_vid.title',
>'video_time': 'part_vid.runtime',
>'video_cost': 'cost'
>   }
>userform.save(data)
>// videodata
>vdata = {'video_id': 'part_vid.id',
> 'video_name': 'part_vid.title',
> 'video_time': 'part_vid.runtime',
> 'video_cost': 'cost',
> 'lecturer_id': 'k',
> 'lecturer_name': 'lecturer_name'
>}
>videoform.save(vdata)
>
>return HttpResponseRedirect(reverse('video.views.play_vid',
> args=(cat_id, this_vid_id,)))
>else:
>form = CertForm(request.POST)
>
> all the stuff in data and vdata is derived from query sets prior to the
> form
>
> Q
> 1 Why am I getting "'UserAccountForm' object has no attribute
> 'cleaned_data'"
> 2 If I use if userform.is_valid() then userform is invalid in any case
> 3 Just save the data given to another model 'Accounts' is all I want it to
> do but it has to be done in here as this is where the agree is done
> --
> View this message in context:
> http://old.nabble.com/what-am-I-doing-wrong--tp30760259p30760259.html
> Sent from the django-users mailing list archive at Nabble.com.
>
> --
> 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
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Robert McQueen
Massachusetts Institute of Technology
Class of 2012, Course 6.3 - Computer Science

rmcqu...@mit.edu

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: File Uploads Form Field "title" Questions

2011-01-27 Thread Rob McQueen
I think this is trivial considering that the example does not use
request.POST['title'] They must of just forgot to use the title field in the
view?

One practical example could be to use the title as the filename which you
intend to store in your filesystem. You can do this by changing the filename
of the file object to the "title" string you stored in the request. This
would be done in a view method.

-Rob

On Thu, Jan 27, 2011 at 10:53 AM, hank23  wrote:

> I'm trying to code and implement a file upload screen. I've looked at
> the documentation at:
>
> http://docs.djangoproject.com/en/1.2/topics/http/file-uploads/
>
> and the document shows a simple upload form called UploadFileForm
> which is shown with two fields coded for it. I'm assuming that the
> field named "file" of type forms.FileField is just the file
> itself(location, name, and data), but if so what's the "title" field
> of type forms.CharField used for and how is it processed? I don't
> think it's mentioned at all in the documentation except for being
> shown to be part of the form. Can someone please explain its use and
> how it should be processed? Thanks.
>
> --
> 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
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Robert McQueen
Massachusetts Institute of Technology
Class of 2012, Course 6.3 - Computer Science

rmcqu...@mit.edu

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.