Re: Need to change newform label from within view

2008-02-21 Thread csmith87

Actually, it looks like I can use a formfield callback.   Not sure
exactly how to do it yet, but
they are described in the djangoproject newforms library doc.

On Feb 21, 2:51 pm, Michael Newman <[EMAIL PROTECTED]> wrote:
> not in the views per se, but you can certainly take care of this in
> the templates, just manually define each of the fields.
>
> On Feb 21, 1:23 pm, csmith87 <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > Newbie django user 
>
> > Is it possible to change a newform label (from the one in the model)
> > to one
> > set in the view ?   (i.e. I want the tags lefttag, righttag) in the
> > view below to
> > appear in the generated form as the label, not the model label.
>
> > Thanks in advance ...
>
> > Here is my model ...
>
> > class Response( models.Model ):
>
> > type = models.IntegerField()
> > left = models.TextField()
> > right = models.TextField()
> > login_id = models.CharField( maxlength=32 )
> > entry_date = models.DateTimeField()
>
> > class Admin:
> > pass
>
> > Here is my view ...
>
> > def getif( request ):
> > lefttag = 'if'
> > righttag = 'then'
> > AddResponseForm = forms.form_for_model( Response )
>
> > if request.method == 'POST':
> > form = AddResponseForm( request.POST )
> > if form.is_valid():
> > form.save()
> > return HttpResponseRedirect( '/if' )
> > else:
> > form = AddResponseForm()
>
> >
return render_to_response( 'AddResponseForm.html', {'form':
form } )
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Need to change newform label from within view

2008-02-21 Thread Michael Newman

not in the views per se, but you can certainly take care of this in
the templates, just manually define each of the fields.

On Feb 21, 1:23 pm, csmith87 <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Newbie django user 
>
> Is it possible to change a newform label (from the one in the model)
> to one
> set in the view ?   (i.e. I want the tags lefttag, righttag) in the
> view below to
> appear in the generated form as the label, not the model label.
>
> Thanks in advance ...
>
> Here is my model ...
>
> class Response( models.Model ):
>
> type = models.IntegerField()
> left = models.TextField()
> right = models.TextField()
> login_id = models.CharField( maxlength=32 )
> entry_date = models.DateTimeField()
>
> class Admin:
> pass
>
> Here is my view ...
>
> def getif( request ):
> lefttag = 'if'
> righttag = 'then'
> AddResponseForm = forms.form_for_model( Response )
>
> if request.method == 'POST':
> form = AddResponseForm( request.POST )
> if form.is_valid():
> form.save()
> return HttpResponseRedirect( '/if' )
> else:
> form = AddResponseForm()
>
> return render_to_response( 'AddResponseForm.html', {'form': form } )
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Need to change newform label from within view

2008-02-21 Thread csmith87

Hello,

Newbie django user 

Is it possible to change a newform label (from the one in the model)
to one
set in the view ?   (i.e. I want the tags lefttag, righttag) in the
view below to
appear in the generated form as the label, not the model label.

Thanks in advance ...

Here is my model ...

class Response( models.Model ):

type = models.IntegerField()
left = models.TextField()
right = models.TextField()
login_id = models.CharField( maxlength=32 )
entry_date = models.DateTimeField()

class Admin:
pass

Here is my view ...

def getif( request ):
lefttag = 'if'
righttag = 'then'
AddResponseForm = forms.form_for_model( Response )

if request.method == 'POST':
form = AddResponseForm( request.POST )
if form.is_valid():
form.save()
return HttpResponseRedirect( '/if' )
else:
form = AddResponseForm()


return render_to_response( 'AddResponseForm.html', {'form': form } )



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---