├── .bumpversion.cfg ├── .gitignore ├── LICENSE ├── MANIFEST.in ├── README.md ├── floppyforms_bootstrap3 ├── __init__.py ├── admin.py ├── models.py ├── templates │ └── floppyforms │ │ ├── attrs.html │ │ ├── errors.html │ │ ├── layouts │ │ ├── bootstrap3-horizontal.html │ │ └── bootstrap3-inline.html │ │ └── rows │ │ ├── bootstrap3-horizontal.html │ │ └── bootstrap3-inline.html ├── tests.py └── views.py ├── setup.cfg └── setup.py /.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 0.0.0 3 | files = setup.py 4 | commit = True 5 | tag = True 6 | message = Release version {new_version}. 7 | 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | dist/ 3 | *.egg-info/ 4 | 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 George Goldberg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include *.md LICENSE 2 | recursive-include floppyforms_bootstrap3/templates * 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | django-floppyforms-bootstrap3 2 | ============================= 3 | 4 | Bootstrap 3 Friendly Templates for Django Floppy Forms 5 | 6 | The aim of this is to provide Django Floppy Forms templates that produce nice Bootstrap 3 HTML with 7 | minimal effort, so you can get something nice looking for your Bootstrap powered site quickly and 8 | easily, and also to give a starting point for further customisation. 9 | 10 | This project is currently incomplete. I'm only implementing bits as and when I need them. However, 11 | I am very happy to receive merge requests that get more of it finished. 12 | 13 | What Works So Far? 14 | ================== 15 | 16 | * The Bootstrap 3 Horizontal Form layout http://getbootstrap.com/css/#forms-horizontal 17 | 18 | How To Use 19 | ========== 20 | 21 | * Clone the git repo into the base directory of your Django Project, and add it to settings.py just like any other app. 22 | * Make sure this app is included in setings.py apps *before* floppy forms, as otherwise the template overriding doesn't seem to work properly. 23 | * Use floppyforms as normal. 24 | * Start with the example code below for how to use it. 25 | 26 | Example 27 | ======= 28 | 29 | The example below gives a Bootstrap 3 Horizontal Form Layout. 30 | 31 |
32 |
33 | {% csrf_token %} 34 | {% form comment_form using "floppyforms/layouts/bootstrap3-horizontal.html" %} 35 |
36 |
37 | 38 |
39 |
40 |
41 |
42 | 43 | Sources 44 | ======= 45 | 46 | The code in this repository was based off the Bootstrap 2 example in the FloppyForms documentation, 47 | as well as comments at https://github.com/gregmuellegger/django-floppyforms/issues/86 48 | 49 | 50 | -------------------------------------------------------------------------------- /floppyforms_bootstrap3/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/grundleborg/django-floppyforms-bootstrap3/951814e2b9957417423150b456240c1db4d6e589/floppyforms_bootstrap3/__init__.py -------------------------------------------------------------------------------- /floppyforms_bootstrap3/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /floppyforms_bootstrap3/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /floppyforms_bootstrap3/templates/floppyforms/attrs.html: -------------------------------------------------------------------------------- 1 | {% if "class" in attrs.keys %} 2 | {% for name, value in attrs.items %} {{ name }}{% if name == "class" %}="form-control {{ value }}"{% elif value != True %}="{{ value }}"{% endif %}{% endfor %} 3 | {% else %} 4 | {% for name, value in attrs.items %} {{ name }}{% if value != True %}="{{ value }}"{% endif %}{% endfor %} class="form-control" 5 | {% endif %} 6 | -------------------------------------------------------------------------------- /floppyforms_bootstrap3/templates/floppyforms/errors.html: -------------------------------------------------------------------------------- 1 | {% if errors %}{% for error in errors %}{{ error }}{% if not forloop.last %}
{% endif %}{% endfor %}
{% endif %} 2 | -------------------------------------------------------------------------------- /floppyforms_bootstrap3/templates/floppyforms/layouts/bootstrap3-horizontal.html: -------------------------------------------------------------------------------- 1 | {% load floppyforms %}{% block formconfig %}{% formconfig row using "floppyforms/rows/bootstrap3-horizontal.html" %}{% endblock %} 2 | 3 | {% block forms %}{% for form in forms %} 4 | {% block errors %} 5 | {% for error in form.non_field_errors %} 6 |
7 | × 8 | {{ error }} 9 |
10 | {% endfor %} 11 | {% for error in form|hidden_field_errors %} 12 |
13 | × 14 | {{ error }} 15 |
16 | {% endfor %} 17 | {% endblock errors %} 18 | {% block rows %} 19 | {% for field in form.visible_fields %} 20 | {% if forloop.last %}{% formconfig row with hidden_fields=form.hidden_fields %}{% endif %} 21 | {% block row %}{% formrow field %}{% endblock %} 22 | {% endfor %} 23 | {% if not form.visible_fields %}{% for field in form.hidden_fields %}{% formfield field %}{% endfor %}{% endif %} 24 | {% endblock %} 25 | {% endfor %}{% endblock %} 26 | -------------------------------------------------------------------------------- /floppyforms_bootstrap3/templates/floppyforms/layouts/bootstrap3-inline.html: -------------------------------------------------------------------------------- 1 | {% load floppyforms %}{% block formconfig %}{% formconfig row using "floppyforms/rows/bootstrap3-inline.html" %}{% endblock %} 2 | 3 | {% block forms %}{% for form in forms %} 4 | {% block errors %} 5 | {% for error in form.non_field_errors %} 6 |
7 | × 8 | {{ error }} 9 |
10 | {% endfor %} 11 | {% for error in form|hidden_field_errors %} 12 |
13 | × 14 | {{ error }} 15 |
16 | {% endfor %} 17 | {% endblock errors %} 18 | {% block rows %} 19 | {% for field in form.visible_fields %} 20 | {% if forloop.last %}{% formconfig row with hidden_fields=form.hidden_fields %}{% endif %} 21 | {% block row %}{% formrow field %}{% endblock %} 22 | {% endfor %} 23 | {% if not form.visible_fields %}{% for field in form.hidden_fields %}{% formfield field %}{% endfor %}{% endif %} 24 | {% endblock %} 25 | {% endfor %}{% endblock %} 26 | -------------------------------------------------------------------------------- /floppyforms_bootstrap3/templates/floppyforms/rows/bootstrap3-horizontal.html: -------------------------------------------------------------------------------- 1 | {% load floppyforms %}{% block row %}{% for field in fields %} 2 |
3 | {% with classes=field.css_classes label=label|default:field.label help_text=help_text|default:field.help_text %} 4 | {% block label %}{% if field|id %}{% endif %}{% endblock %} 5 | {% block field %} 6 |
7 | {% block widget %}{% formfield field %}{% endblock %} 8 | {% block errors %}{% include "floppyforms/errors.html" with errors=field.errors %}{% endblock %} 9 | {% block help_text %}{% if field.help_text %} 10 |

{{ field.help_text }}

11 | {% endif %}{% endblock %} 12 | {% block hidden_fields %}{% for field in hidden_fields %}{{ field.as_hidden }}{% endfor %}{% endblock %} 13 |
14 | {% endblock %} 15 | {% endwith %} 16 |
17 | {% endfor %}{% endblock %} 18 | -------------------------------------------------------------------------------- /floppyforms_bootstrap3/templates/floppyforms/rows/bootstrap3-inline.html: -------------------------------------------------------------------------------- 1 | {% load floppyforms %}{% block row %}{% for field in fields %} 2 |
3 | {% with classes=field.css_classes label=label|default:field.label help_text=help_text|default:field.help_text %} 4 | {% block label %}{% if field|id %}{% endif %}{% endblock %} 5 | {% block field %} 6 | {% block widget %}{% formfield field %}{% endblock %} 7 | {% block hidden_fields %}{% for field in hidden_fields %}{{ field.as_hidden }}{% endfor %}{% endblock %} 8 | {% endblock %} 9 | {% endwith %} 10 |
11 | {% endfor %}{% endblock %} 12 | -------------------------------------------------------------------------------- /floppyforms_bootstrap3/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /floppyforms_bootstrap3/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from setuptools import setup 4 | 5 | def read(*paths): 6 | """Build a file path from *paths* and return the contents.""" 7 | with open(os.path.join(*paths), 'r') as f: 8 | return f.read() 9 | 10 | setup( 11 | name='django-floppyforms-bootstrap3', 12 | version='0.0.0', 13 | packages=['floppyforms_bootstrap3',], 14 | description='A Plugin for Django Floppy Forms that provides Bootstrap 3 based form templates.', 15 | long_description=(read('README.md')), 16 | url='https://github.com/grundleborg/django-floppyforms-bootstrap3', 17 | license='MIT', 18 | author='George Goldberg', 19 | author_email='george@grundleborg.com', 20 | include_package_data=True, 21 | classifiers=[ 22 | 'Development Status :: 2 - Pre-Alpha', 23 | 'Environment :: Web Environment', 24 | 'Framework :: Django', 25 | 'Intended Audience :: Developers', 26 | 'Natural Language :: English', 27 | 'License :: OSI Approved :: MIT License', 28 | 'Operating System :: OS Independent', 29 | 'Programming Language :: Python', 30 | 'Programming Language :: Python :: 3', 31 | 'Programming Language :: Python :: 3.3', 32 | 'Topic :: Internet :: WWW/HTTP', 33 | 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 34 | ], 35 | install_requires=[ "django-floppyforms", ], 36 | ) 37 | --------------------------------------------------------------------------------