On 9 March 2010 05:54, MMRUser <oshadha.ro...@gmail.com> wrote:
> Thanks another doubt,what about the css mappings class="field text
> medium" do they also need to include in the class definition in
> Django.
>
> On Mar 9, 9:21 am, rebus_ <r.dav...@gmail.com> wrote:
>> On 9 March 2010 05:04, MMRUser <oshadha.ro...@gmail.com> wrote:
>>
>>
>>
>> > I have an pre-built HTML form (means I design the HTML form
>> > separately) and I need to reuse it with Django form class
>> > (django.forms), So how do I incorporate my HTML form with Django form
>> > class. for example
>>
>> > HTML:
>>
>> > <li id="foli11" class="">
>> >  <label class="desc" id="title11" for="Field11">
>> >  Username
>> >  <span id="req_0" class="req">*</span>
>> >  </label>
>> >  <div class="col">
>> >  <input id="Field11" name="Field11" type="text" class="field text
>> > medium" value="" maxlength="255" tabindex="11" />
>> >  </div>
>> > </li>
>>
>> > How do I map this HTML in to Django form definition, I know that it
>> > can be done by modifying Django form fields according to this HTML.
>> > But I guess it's a time consuming approach,so I would like to know
>> > that is there any easy and time saving solutions for this issue.
>>
>> > 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-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to 
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group 
>> > athttp://groups.google.com/group/django-users?hl=en.
>>
>> Well usually you first create a form in django and use its instance to
>> generate the HTML.
>>
>> You can also write the HTML by yourself and all you need to be careful
>> of is that name and id attributes of you inputs and input type are
>> same as in the class you define.
>>
>> Your HTML corresponds to:
>>
>> class MyForm(forms.Form):
>>    Field11 = forms.CharField(label="Username",  max_length=255)
>>
>> I highly recommend to first setup a form class then write HTML and
>> making form fields have more sensible names then Field11.
>>
>> Also i suggest these links as further reading:
>>
>> http://docs.djangoproject.com/en/dev/topics/forms/http://docs.djangoproject.com/en/dev/ref/forms/api/http://docs.djangoproject.com/en/dev/ref/forms/fields/
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>

No, CSS classes are not defined in form class (as far as i know).

I would suggest using reusable form templates [1] and putting the CSS
classes on field wrappers for example.

This is what you are interested in:

http://docs.djangoproject.com/en/dev/topics/forms/#reusable-form-templates
http://docs.djangoproject.com/en/dev/topics/forms/#displaying-a-form-using-a-template

Which ever approach you decide to use is valid, but writing a bunch of
your own HTML for forms takes more time but is also more customisable,
on the other hand using shortcut methods such as "as_p" [1] or
"as_table" [2] is faster but you have less control over the outputted
HTML.

[1] http://docs.djangoproject.com/en/dev/ref/forms/api/#as-p
[2] http://docs.djangoproject.com/en/dev/ref/forms/api/#as-table

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

Reply via email to