Commit 1c49d963 authored by Michael Fladischer's avatar Michael Fladischer

Import python-django-crispy-forms_1.6.1.orig.tar.gz

parent 8d1af358
* Package version:
* Django version:
* Python version:
### Description:
// REPLACE ME: What are you trying to get done, what has happened, what went wrong, and what did you expect?
### Preferably also include:
-[ ] Example Django Crispy Forms code
-[ ] Screenshots
-[ ] Actual HTML generated
-[ ] Exepcted HTML
......@@ -11,7 +11,10 @@ python:
env:
- DJANGO='django>=1.8.0,<1.9.0'
- DJANGO='django>=1.9.0,<1.10.0'
- DJANGO='django>=1.10.0,<1.11.0'
- DJANGO='https://github.com/django/django/archive/master.tar.gz'
before_install:
- pip install --upgrade 'pytest<3.0.0'
install:
- pip install $DJANGO
- pip install -e .
......@@ -23,10 +26,14 @@ matrix:
exclude:
- python: "3.2"
env: DJANGO='https://github.com/django/django/archive/master.tar.gz'
- python: "3.2"
env: DJANGO='django>=1.10.0,<1.11.0'
- python: "3.2"
env: DJANGO='django>=1.9.0,<1.10.0'
- python: "3.3"
env: DJANGO='https://github.com/django/django/archive/master.tar.gz'
- python: "3.3"
env: DJANGO='django>=1.10.0,<1.11.0'
- python: "3.3"
env: DJANGO='django>=1.9.0,<1.10.0'
- python: "3.4"
......
# CHANGELOG for django-crispy-forms
## 1.6.1 (2016/10/17)
* Updates compatibility for Django 1.10
* A number of small Bootstrap 4 fixes.
See [1.6.1 Milestone](https://github.com/django-crispy-forms/django-crispy-forms/milestone/3?closed=1)
for full issue list.
## 1.6.0 (2016/1/7)
* Fixed compatibility with Django 1.9
* Dropped support for Django 1.7
* Added Bootstrap 4 template pack
* Other small fixes.
......
......@@ -106,3 +106,4 @@ Contributors
* John Comeau <jcomeauictx>
* Yoong Kang Lim <yoongkang>
* Dmitry Dygalo <Stranger6667>
* Lee Skillen <lskillen>
......@@ -4,4 +4,4 @@ include MANIFEST.in
include README.rst
recursive-include crispy_forms/static *
recursive-include crispy_forms/templates *
recursive-include crispy_forms/tests *.py
recursive-include crispy_forms/tests *.py *.html
......@@ -11,6 +11,8 @@ django-crispy-forms
The best way to have Django_ DRY forms. Build programmatic reusable layouts out of components, having full control of the rendered HTML without writing HTML in templates. All this without breaking the standard way of doing things in Django, so it plays nice with any other form application.
`django-crispy-forms` supports Python 2.7/Python 3.2+ and Django 1.8+
The application mainly provides:
* A filter named ``|crispy`` that will render elegant div based forms. Think of it as the built-in methods: ``as_table``, ``as_ul`` and ``as_p``. You cannot tune up the output, but it is easy to start using it.
......@@ -20,7 +22,7 @@ Django-crispy-forms supports several frontend frameworks, such as Twitter `Boots
.. _`Uni-form`: http://sprawsm.com/uni-form
.. _`Bootstrap`: http://twitter.github.com/bootstrap/index.html
.. _`see the docs`: http://django-crispy-forms.rtfd.org
.. _`see the docs`: https://django-crispy-forms.readthedocs.io
Authors
=======
......@@ -33,7 +35,7 @@ If you are upgrading from django-uni-form, we have `instructions`_ for helping y
.. _`Daniel Greenfeld`: https://github.com/pydanny
.. _`Miguel Araujo`: https://github.com/maraujop
.. _`instructions`: http://django-crispy-forms.readthedocs.org/en/1.1.1/migration.html
.. _`instructions`: https://django-crispy-forms.readthedocs.io/en/latest/install.html#moving-from-django-uni-form-to-django-crispy-forms
Example
=======
......@@ -49,7 +51,7 @@ Documentation
For extensive documentation see the ``docs`` folder or `read it on readthedocs`_
.. _`read it on readthedocs`: http://django-crispy-forms.readthedocs.org/en/latest/index.html
.. _`read it on readthedocs`: https://django-crispy-forms.readthedocs.io/en/latest/index.html
Special thanks
==============
......@@ -62,9 +64,5 @@ Special thanks
.. _`@pydanny`: https://github.com/pydanny
.. _`@kennethlove`: https://github.com/kennethlove
Note
----
django-crispy-forms supports Django 1.3 or higher with Python 2.6.x, Python 2.7.x and Python 3.3.x. If you need to support Python 2.5 or Django 1.2 you will need to use a version of django-crispy-forms less than 1.3. For earlier versions of Django or Python you will need to use django-uni-form 0.7.0.
.. _Django: http://djangoproject.com
# -*- coding: utf-8 -*-
__version__ = '1.6.0'
__version__ = '1.6.1'
......@@ -36,6 +36,8 @@ class PrependedAppendedText(Field):
'input_size': self.input_size,
'active': getattr(self, "active", False)
}
if hasattr(self, 'wrapper_class'):
extra_context['wrapper_class'] = self.wrapper_class
template = self.get_template_name(template_pack)
return render_field(
self.field, form, form_style, context,
......@@ -243,7 +245,7 @@ class ContainerHolder(Div):
target = self.first_container_with_errors(form.errors.keys())
if target is None:
target = self.fields[0]
if not target._active_originally_included:
if not getattr(target, '_active_originally_included', None):
target.active = True
return target
......
......@@ -24,8 +24,8 @@
<label for="{{ field.id_for_label }}" class="checkbox {% if field.field.required %}requiredField{% endif %}">
{% crispy_field field %}
{{ field.label|safe }}
{% include 'bootstrap/layout/help_text_and_errors.html' %}
</label>
{% include 'bootstrap/layout/help_text_and_errors.html' %}
{% else %}
{% crispy_field field %}
{% include 'bootstrap/layout/help_text_and_errors.html' %}
......
<div {% if buttonholder.css_id %}id="{{ buttonholder.css_id }}"{% endif %}
class="buttonHolder{% if buttonholder.css_class %} {{ buttonholder.css_class }}{% endif %}">
{{ fields_output|safe }}
</div>
......@@ -38,7 +38,7 @@
<tr>
{% for field in form %}
{% include 'bootstrap/field.html' with tag="th" form_show_labels=False %}
{% include 'bootstrap/field.html' with tag="td" form_show_labels=False %}
{% endfor %}
</tr>
{% endfor %}
......
......@@ -29,8 +29,8 @@
<label for="{{ field.id_for_label }}" class="{% if field.field.required %} requiredField{% endif %}">
{% crispy_field field %}
{{ field.label|safe }}
{% include 'bootstrap3/layout/help_text_and_errors.html' %}
</label>
{% include 'bootstrap3/layout/help_text_and_errors.html' %}
{% else %}
<div class="controls {{ field_class }}">
{% crispy_field field %}
......
......@@ -3,7 +3,7 @@
{% if field.is_hidden %}
{{ field }}
{% else %}
<div id="div_{{ field.auto_id }}" class="form-group{% if form_show_errors and field.errors %} has-error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
<div id="div_{{ field.auto_id }}" class="form-group{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors and field.errors %} has-error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
{% if field.label and form_show_labels %}
<label for="{{ field.id_for_label }}" class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
......
......@@ -38,7 +38,7 @@
<tr>
{% for field in form %}
{% include 'bootstrap3/field.html' with tag="th" form_show_labels=False %}
{% include 'bootstrap3/field.html' with tag="td" form_show_labels=False %}
{% endfor %}
</tr>
{% endfor %}
......
......@@ -4,14 +4,14 @@
{{ field }}
{% else %}
{% if field|is_checkbox %}
<div class="form-group row">
<div class="form-group">
{% if label_class %}
<div class="controls col-{{ bootstrap_device_type }}-offset-{{ label_size }} {{ field_class }}">
<div class="col-{{ bootstrap_device_type }}-offset-{{ label_size }} {{ field_class }}">
{% endif %}
{% endif %}
<{% if tag %}{{ tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" {% if not field|is_checkbox %}class="form-group row{% else %}class="checkbox{% endif %}{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors%}{% if field.errors %} has-error{% endif %}{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
<{% if tag %}{{ tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" {% if not field|is_checkbox %}class="form-group{% else %}class="checkbox{% endif %}{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors%}{% if field.errors %} has-danger{% endif %}{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
{% if field.label and not field|is_checkbox and form_show_labels %}
<label for="{{ field.id_for_label }}" class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
<label for="{{ field.id_for_label }}" class="form-control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
{% endif %}
......@@ -29,10 +29,10 @@
<label for="{{ field.id_for_label }}" class="{% if field.field.required %} requiredField{% endif %}">
{% crispy_field field %}
{{ field.label|safe }}
{% include 'bootstrap4/layout/help_text_and_errors.html' %}
</label>
{% include 'bootstrap4/layout/help_text_and_errors.html' %}
{% else %}
<div class="controls {{ field_class }}">
<div class="{{ field_class }}">
{% crispy_field field %}
{% include 'bootstrap4/layout/help_text_and_errors.html' %}
</div>
......
{% if inputs %}
<div class="form-group row">
<div class="form-group">
{% if label_class %}
<div class="aab controls {{ label_class }}"></div>
<div class="aab {{ label_class }}"></div>
{% endif %}
<div class="controls {{ field_class }}">
<div class="{{ field_class }}">
{% for input in inputs %}
{% include "bootstrap4/layout/baseinput.html" %}
{% endfor %}
......
{% load crispy_forms_filters %}
{% load l10n %}
<div class="controls {{ field_class }}"{% if flat_attrs %} {{ flat_attrs|safe }}{% endif %}>
<div class="{{ field_class }}"{% if flat_attrs %} {{ flat_attrs|safe }}{% endif %}>
{% include 'bootstrap4/layout/field_errors_block.html' %}
{% for choice in field.field.choices %}
......
{% if field.is_hidden %}
{{ field }}
{% else %}
<div id="div_{{ field.auto_id }}" class="form-group row{% if form_show_errors and field.errors %} has-error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
<div id="div_{{ field.auto_id }}" class="form-group{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors and field.errors %} has-danger{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
{% if field.label %}
<label for="{{ field.auto_id }}" class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
<label for="{{ field.auto_id }}" class="form-control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
{% endif %}
......
{% load crispy_forms_field %}
<div{% if div.css_id %} id="{{ div.css_id }}"{% endif %} class="form-group row{% if form_show_errors and field.errors %} has-error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}{% if div.css_class %} {{ div.css_class }}{% endif %}" {{ div.flat_attrs|safe }}>
<div{% if div.css_id %} id="{{ div.css_id }}"{% endif %} class="form-group{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors and field.errors %} has-danger{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}{% if div.css_class %} {{ div.css_class }}{% endif %}" {{ div.flat_attrs|safe }}>
{% if field.label and form_show_labels %}
<label for="{{ field.id_for_label }}" class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
<label for="{{ field.id_for_label }}" class="form-control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
{% endif %}
<div class="controls {{ field_class }}">
<div class="{{ field_class }}">
<div class="input-group">
{% crispy_field field %}
<span class="input-group-btn{% if active %} active{% endif %}{% if input_size %} {{ input_size }}{% endif %}">{{ buttons|safe }}</span>
......
<div{% if formactions.attrs %} {{ formactions.flat_attrs|safe }}{% endif %} class="form-group row">
<div{% if formactions.attrs %} {{ formactions.flat_attrs|safe }}{% endif %} class="form-group">
{% if label_class %}
<div class="aab controls {{ label_class }}"></div>
<div class="aab {{ label_class }}"></div>
{% endif %}
<div class="controls {{ field_class }}">
<div class="{{ field_class }}">
{{ fields_output|safe }}
</div>
</div>
{% if field.help_text %}
{% if help_text_inline %}
<span id="hint_{{ field.auto_id }}" class="help-block">{{ field.help_text|safe }}</span>
<span id="hint_{{ field.auto_id }}" class="text-muted">{{ field.help_text|safe }}</span>
{% else %}
<p id="hint_{{ field.auto_id }}" class="help-block">{{ field.help_text|safe }}</p>
<small id="hint_{{ field.auto_id }}" class="text-muted">{{ field.help_text|safe }}</small>
{% endif %}
{% endif %}
......@@ -3,15 +3,15 @@
{% if field.is_hidden %}
{{ field }}
{% else %}
<div id="div_{{ field.auto_id }}" class="form-group row{% if form_show_errors and field.errors %} has-error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
<div id="div_{{ field.auto_id }}" class="form-group{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors and field.errors %} has-danger{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
{% if field.label and form_show_labels %}
<label for="{{ field.id_for_label }}" class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
<label for="{{ field.id_for_label }}" class="form-control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
{% endif %}
<div class="controls {{ field_class }}">
<div class="{{ field_class }}">
{% if field|is_select %}
{% if crispy_prepended_text %}<span class="input-group{% if active %} active{% endif %}{% if input_size %} {{ input_size }}{% endif %}">{{ crispy_prepended_text|safe }}</span>{% endif %}
{% crispy_field field %}
......
{% load crispy_forms_filters %}
{% load l10n %}
<div class="controls {{ field_class }}"{% if flat_attrs %} {{ flat_attrs|safe }}{% endif %}>
<div class="{{ field_class }}"{% if flat_attrs %} {{ flat_attrs|safe }}{% endif %}>
{% include 'bootstrap4/layout/field_errors_block.html' %}
{% for choice in field.field.choices %}
......
{% if field.is_hidden %}
{{ field }}
{% else %}
<div id="div_{{ field.auto_id }}" class="form-group row{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors and field.errors %} has-error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
<div id="div_{{ field.auto_id }}" class="form-group{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if form_show_errors and field.errors %} has-danger{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
{% if field.label %}
<label for="{{ field.auto_id }}" class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
<label for="{{ field.auto_id }}" class="form-control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
{% endif %}
......
{% load crispy_forms_field %}
<div id="div_{{ field.auto_id }}" class="form-group row{% if form_show_errors and field.errors %} error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
<label class="control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}</label>
<div class="controls {{ field_class }}">
<div id="div_{{ field.auto_id }}" class="form-group{% if form_show_errors and field.errors %} error{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
<label class="form-control-label {{ label_class }}{% if field.field.required %} requiredField{% endif %}">{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}</label>
<div class="{{ field_class }}">
{% crispy_field field 'disabled' 'disabled' %}
{% include 'bootstrap4/layout/help_text.html' %}
</div>
......
......@@ -21,7 +21,7 @@
<tr>
{% for field in formset.forms.0 %}
{% if field.label and not field|is_checkbox and not field.is_hidden %}
<th for="{{ field.auto_id }}" class="control-label {% if field.field.required %}requiredField{% endif %}">
<th for="{{ field.auto_id }}" class="form-control-label {% if field.field.required %}requiredField{% endif %}">
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</th>
{% endif %}
......@@ -38,7 +38,7 @@
<tr>
{% for field in form %}
{% include 'bootstrap4/field.html' with tag="th" form_show_labels=False %}
{% include 'bootstrap4/field.html' with tag="td" form_show_labels=False %}
{% endfor %}
</tr>
{% endfor %}
......
......@@ -120,6 +120,8 @@ class CrispyFieldNode(template.Node):
and not is_file(field)
):
css_class += ' form-control'
if field.errors:
css_class += ' form-control-danger'
widget.attrs['class'] = css_class
......
......@@ -126,6 +126,7 @@ class BasicNode(template.Node):
response_dict = self.get_response_dict(helper, context, is_formset)
node_context = copy_context(context)
node_context.update(response_dict)
final_context = copy_context(node_context)
# If we have a helper's layout we use it, for the form or the formset's forms
if helper and helper.layout:
......@@ -140,11 +141,11 @@ class BasicNode(template.Node):
forloop.iterate()
if is_formset:
response_dict.update({'formset': actual_form})
final_context['formset'] = actual_form
else:
response_dict.update({'form': actual_form})
final_context['form'] = actual_form
return Context(response_dict)
return final_context
def get_response_dict(self, helper, context, is_formset):
"""
......
<h1>Special custom form with context passthrough</h1>
Got prefix: {{ prefix }}.
{% include "bootstrap/whole_uni_form.html" %}
Got suffix: {{ suffix }}.
......@@ -7,7 +7,10 @@ import django
from django import forms
from django.core.urlresolvers import reverse
from django.forms.models import formset_factory
from django.middleware.csrf import _get_new_csrf_key
try:
from django.middleware.csrf import _get_new_csrf_key
except ImportError:
from django.middleware.csrf import _get_new_csrf_string as _get_new_csrf_key
from django.template import (
TemplateSyntaxError, Context
)
......@@ -148,7 +151,11 @@ def test_html5_required():
form.helper.html5_required = True
html = render_crispy_form(form)
# 6 out of 7 fields are required and an extra one for the SplitDateTimeWidget makes 7.
assert html.count('required="required"') == 7
if django.VERSION < (1, 10):
assert html.count('required="required"') == 7
else:
assert len(re.findall(r'\brequired\b', html)) == 7
form = TestForm()
form.helper = FormHelper()
......@@ -540,7 +547,7 @@ def test_multifield_errors():
assert html.count('error') == 0
@only_bootstrap
@only_bootstrap3
def test_bootstrap_form_show_errors():
form = TestForm({
'email': 'invalidemail',
......@@ -568,6 +575,34 @@ def test_bootstrap_form_show_errors():
assert html.count('error') == 0
@only_bootstrap4
def test_bootstrap_form_show_errors():
form = TestForm({
'email': 'invalidemail',
'first_name': 'first_name_too_long',
'last_name': 'last_name_too_long',
'password1': 'yes',
'password2': 'yes',
})
form.helper = FormHelper()
form.helper.layout = Layout(
AppendedText('email', 'whatever'),
PrependedText('first_name', 'blabla'),
PrependedAppendedText('last_name', 'foo', 'bar'),
AppendedText('password1', 'whatever'),
PrependedText('password2', 'blabla'),
)
form.is_valid()
form.helper.form_show_errors = True
html = render_crispy_form(form)
assert html.count('error') == 3
form.helper.form_show_errors = False
html = render_crispy_form(form)
assert html.count('error') == 0
@only_bootstrap
def test_error_text_inline(settings):
form = TestForm({'email': 'invalidemail'})
......@@ -600,7 +635,7 @@ def test_error_text_inline(settings):
assert len(matches) == 3
@only_bootstrap
@only_bootstrap3
def test_error_and_help_inline():
form = TestForm({'email': 'invalidemail'})
form.helper = FormHelper()
......@@ -630,6 +665,36 @@ def test_error_and_help_inline():
assert error_position < help_position
@only_bootstrap4
def test_error_and_help_inline():
form = TestForm({'email': 'invalidemail'})
form.helper = FormHelper()
form.helper.error_text_inline = False
form.helper.help_text_inline = True
form.helper.layout = Layout('email')
form.is_valid()
html = render_crispy_form(form)
# Check that help goes before error, otherwise CSS won't work
help_position = html.find('<span id="hint_id_email" class="help-inline">')
error_position = html.find('<p id="error_1_id_email" class="help-block">')
assert help_position < error_position
# Viceversa
form = TestForm({'email': 'invalidemail'})
form.helper = FormHelper()
form.helper.error_text_inline = True
form.helper.help_text_inline = False
form.helper.layout = Layout('email')
form.is_valid()
html = render_crispy_form(form)
# Check that error goes before help, otherwise CSS won't work
error_position = html.find('<span id="error_1_id_email" class="help-inline">')
help_position = html.find('<small id="hint_id_email" class="text-muted">')
assert error_position < help_position
@only_bootstrap
def test_form_show_labels():
form = TestForm()
......@@ -690,31 +755,50 @@ def test_template_pack():
@only_bootstrap4
def test_bootstrap4_label_class_and_field_class():
def test_label_class_and_field_class():
form = TestForm()
form.helper = FormHelper()
form.helper.label_class = 'col-lg-2'
form.helper.field_class = 'col-lg-8'
html = render_crispy_form(form)
assert '<div class="form-group row">' in html
assert '<div class="controls col-lg-offset-2 col-lg-8">' in html
assert '<div class="form-group">' in html
assert '<div class="col-lg-offset-2 col-lg-8">' in html
assert html.count('col-lg-8') == 7
form.helper.label_class = 'col-sm-3'
form.helper.field_class = 'col-sm-8'
html = render_crispy_form(form)
assert '<div class="form-group row">' in html
assert '<div class="controls col-sm-offset-3 col-sm-8">' in html
assert '<div class="form-group">' in html
assert '<div class="col-sm-offset-3 col-sm-8">' in html
assert html.count('col-sm-8') == 7
@only_bootstrap4
def test_bootstrap4_template_pack():
def test_template_pack():
form = TestForm()
form.helper = FormHelper()
form.helper.template_pack = 'uni_form'
html = render_crispy_form(form)
assert 'form-control' not in html
assert 'ctrlHolder' in html
def test_passthrough_context():
"""
Test to ensure that context is passed through implicitly from outside of
the crispy form into the crispy form templates.
"""
form = TestForm()
form.helper = FormHelper()
form.helper.template = 'custom_form_template_with_context.html'
c = {
'prefix': 'foo',
'suffix': 'bar'
}
html = render_crispy_form(form, helper=form.helper, context=c)
assert "Got prefix: foo" in html
assert "Got suffix: bar" in html
......@@ -4,7 +4,10 @@ from __future__ import unicode_literals
from django import forms
from django.core.urlresolvers import reverse
from django.forms.models import formset_factory, modelformset_factory
from django.middleware.csrf import _get_new_csrf_key
try:
from django.middleware.csrf import _get_new_csrf_key
except ImportError:
from django.middleware.csrf import _get_new_csrf_string as _get_new_csrf_key
from django.shortcuts import render_to_response
from django.template import (
Context, RequestContext
......@@ -300,8 +303,6 @@ def test_formset_layout(settings):
assert html.count('Note for first form only') == 1
if settings.CRISPY_TEMPLATE_PACK == 'uni_form':
assert html.count('formRow') == 3
elif settings.CRISPY_TEMPLATE_PACK == 'bootstrap4':
assert html.count('row') == 21
else:
assert html.count('row') == 3
......@@ -537,9 +538,7 @@ def test_keepcontext_context_manager(settings):
InlineCheckboxes('alphacheckboxes'),
'numeric_multiple_checkboxes'
)
request_factory = RequestFactory()
request = request_factory.get('/')
context = RequestContext(request, {'form': form})
context = {'form': form}
response = render_to_response('crispy_render_template.html', context)
......
......@@ -98,7 +98,7 @@ def test_field_wrapper_class(settings):
elif settings.CRISPY_TEMPLATE_PACK == 'bootstrap3':
assert html.count('class="form-group testing"') == 1
elif settings.CRISPY_TEMPLATE_PACK == 'bootstrap4':
assert html.count('class="form-group row testing"') == 1
assert html.count('class="form-group testing"') == 1
def test_html_with_carriage_returns(settings):
......@@ -400,7 +400,7 @@ class TestBootstrapLayoutObjects(object):
if settings.CRISPY_TEMPLATE_PACK == 'bootstrap3':
form_group_class = 'form-group'
elif settings.CRISPY_TEMPLATE_PACK == 'bootstrap4':
form_group_class = 'form-group row'
form_group_class = 'form-group'
assert html.count('class="%s extra"' % form_group_class) == 1
assert html.count('autocomplete="off"') == 1
......
......@@ -14,7 +14,7 @@
If you love django-crispy-forms, consider making a small donation <a href="http://flattr.com/thing/512037/django-crispy-forms">on Flattr</a>:
</p>
<p>
<a class="FlattrButton" style="display:none;" rev="flattr;button:compact;" href="http://django-crispy-forms.rtfd.org"></a>
<a class="FlattrButton" style="display:none;" rev="flattr;button:compact;" href="https://django-crispy-forms.readthedocs.io"></a>
<noscript><a href="http://flattr.com/thing/512037/django-crispy-forms" target="_blank">
<img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Click to flattr django-crispy-forms" border="0" /></a></noscript>
</p>
......@@ -39,8 +39,9 @@ Since version 1.1.0, django-crispy-forms has built-in support for different CSS
* ``bootstrap`` `Bootstrap`_ is crispy-forms's default template pack, version 2 of the popular simple and flexible HTML, CSS, and Javascript for user interfaces from Twitter.
* ``bootstrap3`` Twitter Bootstrap version 3.
* ``bootstrap4`` Alpha support for Twitter Bootstrap version 4, which is still in Alpha.
* ``uni-form`` `Uni-form`_ is a nice looking, well structured, highly customizable, accessible and usable forms.
* ``foundation`` `Foundation`_ In creators words "The most advanced responsive front-end framework in the world". This template pack is externally available through `crispy-forms-foundation`_
* ``foundation`` `Foundation`_ In the creator's words, "The most advanced responsive front-end framework in the world." This template pack is externally available through `crispy-forms-foundation`_
If your form CSS framework is not supported and it's open source, you can create a template pack for it and submit a pull request in Github or create a ``crispy-forms-templatePackName`` project and let me know, so I can link it.
......@@ -57,7 +58,7 @@ Please check the documentation of your template pack package for the correct val
Setting media files
~~~~~~~~~~~~~~~~~~~
crispy-forms no longer includes static files. You will need to include yourself the proper corresponding media files, depending on what CSS framework (Template pack) you are using. This might involve one or more CSS and JS files. Read CSS framework's docs for help on how to set it up.
crispy-forms no longer includes static files. You will need to include the proper corresponding media files yourself depending on what CSS framework (Template pack) you are using. This might involve one or more CSS and JS files. Read CSS framework's docs for help on how to set it up.
Moving from django-uni-form to django-crispy-forms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -71,7 +72,7 @@ django-crispy-forms was started as a friendly fork of django-uni-form. We are aw
from uni_form.helper import FormHelper
from crispy_forms.helper import FormHelper
In Linux You can use `rpl`_ to easily find and update the proper lines. Run in the root of your project the following command. It is strongly recommended that you have your project in a VCS or a backup, so you can rollback if something goes wrong::
In Linux You can use `rpl`_ to easily find and update the proper lines. In the root of your project run the following command. It is strongly recommended that you have your project in a VCS or a backup, so you can rollback if something goes wrong::
rpl -R uni_form. crispy_forms. .
......@@ -100,7 +101,7 @@ Using rpl::
rpl -R "|as_uni_errors" "|as_crispy_errors" .
rpl -R "|as_uni_field" "|as_crispy_field" .
There is one filter that has been turned into a tag for extra layout power, so former filter name will not work. You will only need to update this if you have custom or overridden templates in your project::
There is one filter that has been turned into a tag for extra layout power, so the former filter name will not work. You will only need to update this if you have custom or overridden templates in your project::
field|with_class ------> {% crispy_field field %}
......
[metadata]
license-file = LICENSE.txt
[wheel]
universal=1
[tox]
envlist =
{py27,py32,py33,py34,py35}-django18
{py27,py34,py35}-{django19,django-latest}
{py27,py34,py35}-{django19,django110,django-latest}
[testenv]
deps =
django17: django>=1.7.0,<1.8.0
django18: django>=1.8.0,<1.9.0
django19: django>=1.9.0,<1.10.0
django110: django>=1.10.0,<1.11.0
django-latest: https://github.com/django/django/archive/master.tar.gz
whitelist_externals = make
commands = make test
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment