Skip to main content

Django application to add 'django-crispy-forms' layout objects for Foundation

Project description

Introduction

This is a Django application to add django-crispy-forms layout objects for Foundation version 3.5.x.

Actually this is only to use specific templates and changing some CSS class names.

This app does not embed a Foundation release, you will have to install it yourself.

Requires

Installation

Just register the app in your project settings like this :

INSTALLED_APPS = (
    ...
    'crispy_forms',
    'crispy_forms_foundation',
    ...
)

Then append this part to specify usage of the Foundation set :

# Default layout to use with "crispy_forms"
CRISPY_TEMPLATE_PACK = 'foundation'

All other django-crispy-forms settings option apply, see its documentation for more details.

Usage

Import crispy-forms-foundation then you can use the layout object in your forms :

from crispy_forms_foundation.layout import Layout, Fieldset, Field, SplitDateTimeField, RowFluid, Column, Div, ButtonHolder, Submit, HTML

class YourForm(forms.ModelForm):
    """
    *Page* form
    """
    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_action = '.'
        self.helper.layout = Layout(
            Fieldset(
                ugettext('Content'),
                'title',
                'content',
            ),
            Fieldset(
                ugettext('Display settings'),
                RowFluid(
                    Column('template', css_class='six'),
                    Column('order', css_class='three'),
                    Column('visible', css_class='three'),
                ),
            ),
            Fieldset(
                ugettext('Publish settings'),
                'parent',
                RowFluid(
                    Column(SplitDateTimeField('published'), css_class='six'),
                    Column('slug', css_class='six'),
                ),
            ),
            ButtonHolder(
                Submit('submit_and_continue', ugettext('Save and continue')),
                Submit('submit', ugettext('Save')),
            ),
        )

        super(YourForm, self).__init__(*args, **kwargs)

The embedded templates are in crispy_forms_foundation/templates/foundation.

Layout items

For now there is only three layout items dedicated to Foundation (Row, RowFluid, Column), other embedded items are cloned from the uni_form layout items from django-crispy-forms.

Row

Act as a div container row, it will embed his items in a div like this :

<div class"row">Your stuff</div>

RowFluid

It has a same behaviour than Row but add a CSS class “row-fluid” that you can use to have top level row that take all the container width. You have to put the CSS for this class to your CSS stylesheet. It will embed his items in a div like this :

<div class"row row-fluid">Your stuff</div>

The CSS to add should be something like this :

.row-fluid {
    width: 100%;
    max-width: 100%;
    min-width: 100%;
}

Column

This is the column from the Foundation Grid, all columns should be contained in a Row or a RowFluid and you will have to define the column type in the css_class attribute.

With a css_class attribute defined to twelve, it will embed his items in a div like this :

<div class"columns twelve">Your stuff</div>

Project details


Release history Release notifications

History Node

0.6.4

History Node

0.6.3

History Node

0.6.2

History Node

0.6.1

History Node

0.6.0

History Node

0.5.5

History Node

0.5.4

History Node

0.5.3

History Node

0.5.2

History Node

0.5.1

History Node

0.5.0

History Node

0.4.1

History Node

0.4

History Node

0.3.9

History Node

0.3.8.2

History Node

0.3.8.1

History Node

0.3.7.1

History Node

0.3.7

History Node

0.3.6

History Node

0.3.5

History Node

0.3.4.1

History Node

0.3.4

History Node

0.3.3

History Node

0.3.2

History Node

0.3.1.1

History Node

0.3.1

History Node

0.3.0

History Node

0.2.4.2

History Node

0.2.4.1

This version
History Node

0.2.4

History Node

0.2.3.1

History Node

0.2.3

History Node

0.2.2

History Node

0.2.1

History Node

0.2

History Node

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
crispy-forms-foundation-0.2.4.tar.gz (9.1 kB) Copy SHA256 hash SHA256 Source None Dec 26, 2013

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page