Writing styled forms with absolutely minimal HTML (Part-2)

By : Rakesh Vidya Chandra

In the earlier post we have cruised through the fundamentals of using crispy forms for writing styled forms with minimal HTML.

At this time, let us dip into getting a clear understanding on how to customize the crispy forms.

Before diving into the crux of this post we will become aware with the following key words:

  1. FormHelper
  2. Layout

FormHelper

  • Django-crispy-forms implements a class called FormHelper to define the form rendering behavior.
  • Helpers give us a way to control the form attributes and its layout.
  • They control global form rendering behavior.

Layout

  • It is an another powerful class of Django-crispy-forms which ...

more info..
Topics : django crispyforms

Django backward relationship lookup

By : Akshar Raaj

I often limit the lookup to fields of the model and forget about backward relations.

Consider the following relationship:

class Group(models.Model):
    name = models.CharField(max_length=100)

class Student(models.Model):
    name = models.CharField(max_length=100)
    group = models.ForeignKey(Group)

A group can have many students.

We want to get the groups based on certain conditions on model Student. An example is getting the groups which contain a student named 'stud1'. If you can get it using model Group and without using Student, you can skip this post.

In such a scenario, we tend to use Student model. It ...

more info..
Topics : django

Writing styled forms with absolutely minimal HTML (Part-1)

By : Rakesh Vidya Chandra

When controlling the form rendering, we all know that we can use the three pre-baked output format of the forms namely: as_u, as_p and as_table.

For example: if we use: {{ registration_form.as_ul}} The output template would be:

<li>
    <label for="id_uname">Userame:</label>
    <input type="text" name="username" id="id_uname">
<li>

<li>
    <label for="id_email">Email:</lable>
    <input type="text" name="email" id="id_email">
<li>

And so on...

Here are some questions that come into the picture:

  1. What if we to want deal with divs?
  2. What if we want to reorder the fields? and what if I have 100 such ...

more info..
© Agiliq, 2009-2012