Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Internet > HTTP (WWW)

    django-form-scaffold 1.1.0

    Download button

    No screenshots available
    Downloads: 187  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Wes Mason | More programs
    The Apache License 2.0 / FREE
    February 16th, 2011, 09:43 GMT
    ROOT / Internet / HTTP (WWW)

     Read user reviews (0)  Refer to a friend  Subscribe

    django-form-scaffold description

    Utility for generating dynamic Django template representations of the inbuilt form.as_p/as_ul/as_table output

    django-form-scaffold is a package of helper functions for generating Django template code with markup from Django form instances.

    It solves the problem of generating, over and over again, markup for a full form which is effectively a templated version of the BaseForm as_p, as_ul and as_table methods output (which output static values, rather than dyanmic Django template code).

    django-form-scaffold outputs in the same form as these methods, but uses the template placeholders for all the form and field values, which is what I find myself doing time and time again as it's easier to control the individual format/styling etc. of fields in a form, and is also generally easier for designers to get their heads around a form template.

    For example, outputting a login form, rather than doing:

    {{ form.as_p }}

    We would do:

    < p >
    {% if form.username.errors %}
     {% for error in form.username.errors %}{{ error }}{% endfor %}
    {% endif %}
    {{ form.username.label }} {{ form.username }}
    < /p >
    < p >
    {% if form.password.errors %}
     {% for error in form.password.errors %}{{ error }}{% endfor %}
    {% endif %}
    {{ form.password.label }} {{ form.password }}
    < /p >


    Installation:

    Install django-form-scaffold using easy_install (or pip):

    easy_install django-form-scaffold

    Or from the setup script:

    python setup.py install

    Usage:


    Form scaffolding is meant for generating content to then be placed in your template files, so you wouldn't called scaffold.as_p from within a template itself.

    The best way to call the scaffold functions are from within a bootstraped Django Python shell, using the management script:

    python manage.py shell

    Then just import scaffold from the dfs namespace, import your form(s), and pass an instance to one of the functions:

     > > > from dfs import scaffold
     > > > from MyProject.MyApp.forms import MyForm
     > > > form = MyForm()
     > > > print scaffold.as_p(form)
    {% if form.email.errors %}{% for error in form.email.errors %}{{ error }}{% endfor %}{% endif %}
    < p >{{ form.email.label }} {{ form.email }}< /p >
    {% if form.password1.errors %}{% for error in form.password1.errors %}{{ error }}{% endfor %}{% endif %}
    < p >{{ form.password1.label }} {{ form.password1 }}< /p >
    {% if form.password2.errors %}{% for error in form.password2.errors %}{{ error }}{% endfor %}{% endif %}
    < p >{{ form.password2.label }} {{ form.password2 }}< /p >

     > > > # We can also use a form class rather than an instance, but
     > > > # this won't always work if your form requires params etc.,
     > > > # this just creates an instance for you anyway.
     > > > print scaffold.as_ul(cls=MyForm)
    < li >{% if form.email.errors %}{% for error in form.email.errors %}{{ error }}{% endfor %}{% endif %}{{ form.email.label }} {{ form.email }}< /li >
    < li >{% if form.password1.errors %}{% for error in form.password1.errors %}{{ error }}{% endfor %}{% endif %}{{ form.password1.label }} {{ form.password1 }}< /li >
    < li >{% if form.password2.errors %}{% for error in form.password2.errors %}{{ error }}{% endfor %}{% endif %}{{ form.password2.label }} {{ form.password2 }}< /li >


    The following helper functions available in dfs.scaffold:
    as_p
     Outputs the same markup < p > style as the inbuilt Django BaseForm.as_p.
    as_ul
     Outputs the same markup < ul > style as the inbuilt Django BaseForm.as_ul.
    as_table
     Outputs the same markup < table > style as the inbuilt Django BaseForm.as_table.
    as_table
     Extra scaffold-only helper to output an alternative < div > based form layout, similar in layout to as_p but with < div >s.

    Product's homepage

    Requirements:

    · Python
    · Django

      


    TAGS:

    helper functions | templated markup | Django forms | Django | forms | helper

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM