Building forms by hands

4 views
Skip to first unread message

Alexander Solovyov

unread,
Jul 4, 2007, 12:23:00 PM7/4/07
to Django users
Hi all.

I want to build forms in HTML by hands, without helpers from django
(like outputting field with label and etc), but I can't find one thing
- how I can get value from field (to select appropriate field in
radioselect, f.e.).

For example, RadioSelect provides unordered list with choices, but I
want to get fieldset - and can't select necessary field.

Thanks in advance.

--
Alexander

Russell Keith-Magee

unread,
Jul 5, 2007, 7:19:45 AM7/5/07
to django...@googlegroups.com

I'm unclear what you're asking here - you say you don't want to use
Django helpers, but they you ask about RadioSelect. Is your problem
with rendering the form, or with getting data from a submitted form?
Can you explain your problem another way, possibly with a more
complete example?

Yours,
Russ Magee %-)

Alexander Solovyov

unread,
Jul 7, 2007, 8:36:50 AM7/7/07
to Django users
On 5 июл, 14:19, "Russell Keith-Magee" <freakboy3...@gmail.com> wrote:

> Can you explain your problem another way, possibly with a more
> complete example?

Ok, I'll try.

I want to enter HTML by hands, but can't determine which radio must be
selected. Form is built with form_for_instance, so it contains values.

Sorry if my description is unclear.

Todd O'Bryan

unread,
Jul 7, 2007, 9:08:19 AM7/7/07
to django...@googlegroups.com

If you don't want to use a to output the form HTML that Django gives
you, you'll need to store some kind of value in the context to let you
know which radio button is selected.

Can I ask why, if you're using form_for_instance, you don't want to use
the form's HTML output as well?

Todd

Alexander Solovyov

unread,
Jul 7, 2007, 10:48:22 AM7/7/07
to Django users
On 7 июл, 16:08, "Todd O'Bryan" <toddobr...@mac.com> wrote:
> On Sat, 2007-07-07 at 12:36 +0000, Alexander Solovyov wrote:
> > On 5 июл, 14:19, "Russell Keith-Magee" <freakboy3...@gmail.com> wrote:
>
> > > Can you explain your problem another way, possibly with a more
> > > complete example?
>
> > Ok, I'll try.
>
> > I want to enter HTML by hands, but can't determine which radio must be
> > selected. Form is built with form_for_instance, so it contains values.
>
> > Sorry if my description is unclear.
>
> If you don't want to use a to output the form HTML that Django gives
> you, you'll need to store some kind of value in the context to let you
> know which radio button is selected.

This is what I was afraid. :)

> Can I ask why, if you're using form_for_instance, you don't want to use
> the form's HTML output as well?

Mmm... I'm using form_for_instance-derived form with many
modifications (Indeed, this is better than using form, written by
hands) - I love automatization. But my colleguaes, who are responsible
for HTML part, doesn't like django-generated forms - they want full
control.

--
Alexander

Steve Bergman

unread,
Jul 7, 2007, 1:14:04 PM7/7/07
to Django users
On Jul 7, 9:48 am, Alexander Solovyov <alexander.solov...@gmail.com>
wrote:

> But my colleguaes, who are responsible
> for HTML part, doesn't like django-generated forms - they want full
> control.

Yeah. Coworkers are a drag. ;-)

You do know that you can place the fields yourself, right?

If your form instance is called 'form' and has fields lastname and
firstname, you can put something like:

<table>
<tr class='polkadot'>
<td>{{ form.lastname }},</td><td>{{ form.firstname }}</td>
</tr>
</table>

in your template and have full control over the way the form looks.

You don't have to accept the default arrangement that Django gives by
default.

HTH,
Steve

Bill Fenner

unread,
Jul 7, 2007, 1:30:35 PM7/7/07
to django...@googlegroups.com
On 7/7/07, Alexander Solovyov <alexander...@gmail.com> wrote:
> Mmm... I'm using form_for_instance-derived form with many
> modifications (Indeed, this is better than using form, written by
> hands) - I love automatization. But my colleguaes, who are responsible
> for HTML part, doesn't like django-generated forms - they want full
> control.

Basic django forms give you full control over the placement of all the
fields. I wrote about a helper function that lets you access
individual radio buttons too, since otherwise you get all the
radiobuttons in one clump. See
http://fenron.blogspot.com/2007/06/custom-radio-field-rendering-with.html
.

Bill

Alexander Solovyov

unread,
Jul 7, 2007, 1:38:33 PM7/7/07
to Django users
On 7 июл, 20:14, Steve Bergman <sbergma...@gmail.com> wrote:
> You do know that you can place the fields yourself, right?

I know that I can. ;) They want to have all this <input>s in HTML.

But, if I can't easily get value from field, they will use
{{ form.field }} notation. :D

--
Alexander

Alexander Solovyov

unread,
Jul 7, 2007, 1:45:05 PM7/7/07
to Django users
On 7 июл, 20:30, "Bill Fenner" <fen...@gmail.com> wrote:
> I wrote about a helper function that lets you access
> individual radio buttons too, since otherwise you get all the
> radiobuttons in one clump. Seehttp://fenron.blogspot.com/2007/06/custom-radio-field-rendering-with....
> .

Thanks! I think this will help a lot!

--
Alexander

Reply all
Reply to author
Forward
0 new messages