Browse Source

Getting started with crispy forms

Rafał Pitoń 11 years ago
parent
commit
647b3f257f

+ 5 - 1
misago/conf/defaults.py

@@ -89,7 +89,7 @@ INSTALLED_APPS = (
     'debug_toolbar',
     'south',
     'pipeline',
-    'floppyforms',
+    'crispy_forms',
     'misago.core',
     'misago.conf',
     'misago.users',
@@ -180,3 +180,7 @@ MISAGO_ADMIN_NAMESPACES = (
 # How long (in minutes) since previous request to admin namespace should
 # admin session last.
 MISAGO_ADMIN_SESSION_EXPIRATION = 60
+
+
+# Default forms templates
+CRISPY_TEMPLATE_PACK = 'bootstrap3'

+ 2 - 2
misago/core/forms.py

@@ -1,5 +1,5 @@
-from floppyforms import *  # noqa
-from floppyforms import Form as BaseForm, ModelForm as BaseModelForm
+from django.forms import *  # noqa
+from django.forms import Form as BaseForm, ModelForm as BaseModelForm
 
 
 class AutoStripWhitespacesMixin(object):

+ 3 - 3
misago/templates/misago/admin/conf/group.html

@@ -1,5 +1,5 @@
 {% extends "misago/admin/conf/index.html" %}
-{% load floppyforms i18n %}
+{% load crispy_forms_filters i18n %}
 
 
 {% block title %}{% trans active_group.name %} | {{ block.super }}{% endblock %}
@@ -32,7 +32,7 @@
     {% if use_single_form_template %}
     <div class="form-body no-fieldsets">
       {% for field in fieldsets.0.form %}
-      {% formrow field using "misago/forms/row.html" %}
+      {{ field|as_crispy_field }}
       {% endfor %}
     </div>
     {% else %}
@@ -44,7 +44,7 @@
         {% endif %}
 
         {% for field in fieldset.form %}
-        {% formrow field using "misago/forms/row.html" %}
+        {{ field|as_crispy_field }}
         {% endfor %}
 
       </fieldset>

+ 0 - 1
misago/templates/misago/forms/field.html

@@ -1 +0,0 @@
-<p class="lead">{{ field.widget }}</p>

+ 0 - 0
misago/templates/misago/forms/form.html


+ 0 - 29
misago/templates/misago/forms/row.html

@@ -1,29 +0,0 @@
-{% load floppyforms %}
-
-{% block row %}
-<div class="form-group {% if field.errors %}has-error has-feedback{% endif %}">
-  {% block label %}
-  <label for="{{ field.html_id }}">{{ field.label }}</label>
-  {% endblock label %}
-  {% block field %}
-    {% block widget %}
-    {% formfield field using "misago/forms/field.html" %}
-    {% endblock widget %}
-    {% block errors %}
-    {% if field.errors %}
-    <span class="glyphicon glyphicon-remove form-control-feedback"></span>
-    <div style="font-weight: bold;">
-      {% for error in field.errors %}
-      <p class="help-block">{{ error }}</p>
-      {% endfor %}
-    </div>
-    {% endif %}
-    {% endblock errors %}
-    {% block helptext %}
-    {% if field.help_text %}
-    <p class="help-block">{{ field.help_text }}</p>
-    {% endif %}
-    {% endblock helptext %}
-  {% endblock field %}
-</div>
-{% endblock row %}