Skip to content

Commit

Permalink
Prepping for cut of 0.5.0 tag
Browse files Browse the repository at this point in the history
  • Loading branch information
pydanny committed Jul 20, 2009
1 parent 66cc352 commit b07233e
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 7 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include CONTRIBUTORS.txt
include LICENSE.txt
include MANIFEST.in
include README
include README.rst
recursive-include docs *
recursive-include uni_form/media *
recursive-include uni_form/templates *
Expand Down
89 changes: 88 additions & 1 deletion docs/usage.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
=====================================
django-uni-form (Django Uni-Form)
=====================================

Django_ forms are easily rendered as tables,
paragraphs, and unordered lists. However, elegantly rendered div based forms
is something you have to do by hand. The purpose of this application is to
provide a simple tag and/or filter that lets you quickly render forms in a div
format.

`Uni-form`_ has been selected as the base model for the design of the forms.

Installing django-uni-form
============================
1. Install as uni_form in your Django apps directory.
2. Copy the site_media files in uni_form to your project site_media directory.
uni-form-generic.css
uni-form.css
uni-form.jquery.js
3. Add 'uni_form' to INSTALLED_APPS in settings.py.


Using the django-uni-form filter (Easy and fun!)
=================================================
1. Add ``{% load uni_form %}`` to the template that calls your form.
Expand All @@ -13,7 +35,7 @@ Using the django-uni-form filter (Easy and fun!)

Using the django-uni-form templatetag in your view (Intermediate)
====================================================================
1. In your form class add the following after field definitions::
1. In your views.py add the following after field definitions::

from django.shortcuts import render_to_response

Expand Down Expand Up @@ -81,3 +103,68 @@ Using the django-uni-form templatetag in your form class (Intermediate)
{% endwith %}


Adding a layout to your form class (Intermediate)
==================================================

Uniform helpers can use layout objects. A layout can consist of fieldsets, rows, columns, HTML and fields. A simple Example::

from django import forms

from uni_form.helpers import FormHelper, Submit, Reset
from uni_form.helpers import Layout, Fieldset, Row, HTML

class LayoutTestForm(forms.Form):

is_company = forms.CharField(label="company", required=False, widget=forms.CheckboxInput())
email = forms.CharField(label="email", max_length=30, required=True, widget=forms.TextInput())
password1 = forms.CharField(label="password", max_length=30, required=True, widget=forms.PasswordInput())
password2 = forms.CharField(label="re-enter password", max_length=30, required=True, widget=forms.PasswordInput())
first_name = forms.CharField(label="first name", max_length=30, required=True, widget=forms.TextInput())
last_name = forms.CharField(label="last name", max_length=30, required=True, widget=forms.TextInput())

# Attach a formHelper to your forms class.
helper = FormHelper()

# Create some HTML that you want in the page.
# Yes, in real life your CSS would be cached, but this is just a simple example.
style = """
<style>
.formRow {
color: red;
}
</style>

"""
# create the layout object
layout = Layout(
# first fieldset shows the company
Fieldset('', 'is_company'),

# second fieldset shows the contact info
Fieldset('Contact details',
HTML(style),
'email',
Row('password1','password2'),
'first_name',
'last_name',
)
)

helper.add_layout(layout)

submit = Submit('add','Add this contact')
helper.add_input(submit)

Then, just like in the previous example, add the following to your template::

{% load uni_form %}
{% with form.helper as helper %}
{% uni_form form helper %}
{% endwith %}


This allows you to group fields in fieldsets, or rows or columns or add HTML between fields etc.


.. _Django: https://djangoproject.com
.. _`Uni-form`: https://sprawsm.com/uni-form
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
from setuptools import setup, find_packages

version = '0.4b1'
version = '0.5.0'

LONG_DESCRIPTION = """
=====================================
django-uni-form (Django Uni-Form)
=====================================
[https://djangoproject.com Django] forms are easily rendered as tables,
Django (https://djangoproject.com ) forms are easily rendered as tables,
paragraphs, and unordered lists. However, elegantly rendered div based forms
is something you have to do by hand. The purpose of this application is to
provide a simple tag and/or filter that lets you quickly render forms in a div
format.
[https://sprawsm.com/uni-form Uni-form] has been selected as the base model
for the design of the forms.
Uni-form (https://sprawsm.com/uni-form) has been selected as the base model for
the design of the forms.
"""

setup(
Expand Down
2 changes: 1 addition & 1 deletion uni_form/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__author__ = "Daniel Greenfeld"
__version__="0.4b"
__version__="0.5.0"

0 comments on commit b07233e

Please sign in to comment.