Full control of form rendering in the templates.

Overview

django-floppyforms

Jazzband GitHub Actions Coverage

Full control of form rendering in the templates.

  • Authors: Gregor Müllegger and many many contributors
  • Original creator: Bruno Renié started this project and kept it going for many years.
  • Licence: BSD
  • Requirements: homework -- read this.

Installation

  • pip install -U django-floppyforms
  • Add floppyforms to your INSTALLED_APPS

For those who want to mix and match with vanilla Django widgets, it is also recommended to put Django's form template directory into your template directories:

# in your template configuration
TEMPLATES = [{
    ...,
    # inside the directories parameter
    'DIRS': [
        # include django's form templates
        os.path.join(
            os.path.dirname(django.__file__), "forms/templates/"
        ),
        ... # the rest of your template directories
}]

For extensive documentation see the docs folder or read it on readthedocs

To install the in-development version of django-floppyforms, run pip install "https://github.com/jazzband/django-floppyforms/tarball/master#egg=django-floppyforms".

Help

Create a ticket in the issues section on github or ask your questions on the #django-floppyforms IRC channel on freenode.

You can get professional consulting regarding django-floppyforms or any other Django related work from django-floppyforms' maintainer Gregor Müllegger.

Bugs

Really? Oh well... Please Report. Or better, fix :) We are happy to help you through the process of fixing and testing a bug. Just get in touch.

Development

Thanks for asking!

Get the code:

git clone [email protected]:jazzband/django-floppyforms.git
cd django-floppyforms
virtualenv env
source env/bin/activate
add2virtualenv .

Install the development requirements:

pip install "tox>=1.8"

Currently, you'll need to install the GeoDjango requirements when running tests.

Run the tests:

tox
tox -e py36-22

You can see all the supported test configurations with tox -l.

Comments
  • How to put in all the types of fields in one map and also all the types of maps in one placeholder ?

    How to put in all the types of fields in one map and also all the types of maps in one placeholder ?

    First of all , a brilliant application , and thank you for all the help till now .

    This is my forms.py

    from django import forms from openmaps.models import Open_Layers from django.contrib.admin import widgets
    import floppyforms as forms class PointWidget(forms.gis.PointWidget, forms.gis.BaseGMapWidget): pass class MultiPointWidget(forms.gis.MultiPointWidget,forms.gis.BaseGMapWidget): pass class LineStringWidget(forms.gis.LineStringWidget,forms.gis.BaseGMapWidget): pass class PolygonWidget(forms.gis.PolygonWidget,forms.gis.BaseGMapWidget): pass class MultiPolygonWidget(forms.gis.MultiPolygonWidget,forms.gis.BaseGMapWidget): pass class GeoForm(forms.Form): point = forms.gis.PointField() multipoint = forms.gis.MultiPointField() line = forms.gis.LineStringField() poly = forms.gis.PolygonField() multipoly= forms.gis.MultiPolygonField()

    According to this , all the points , multipoints , line etc load in separate openlayers maps , but in the same page . Is it by anychance possible to put in all the geometries in one map . And also , allow to change between maps like openlayers , osm , google maps using layerswitcher .

    opened by ghost 29
  • TypeError: get_context() got an unexpected keyword argument 'renderer' on Django 1.11.3

    TypeError: get_context() got an unexpected keyword argument 'renderer' on Django 1.11.3

    The error in the title is raised for Floppyforms widgets on Django 1.11.3 because of the change in this ticket (code here). The solution for now is to stay on 1.11.2 or lower until this is fixed in Floppyforms.

    opened by Gwildor 27
  • local copy of openlayers.js

    local copy of openlayers.js

    hello,

    May be it's no relevant, but I would like to have a local copy of openlayers, and google (js and css) instead of getting them via their absolute URL.

    • how can I achieve this ? (we could have sort of settings for that, instead of modify the widget Media class of BaseGMapWidget BaseOsmWidget or BaseMetacartaWidget)
    • how interesting is it to use, for example django_compressor, to increase performance ?

    thx

    opened by ouhouhsami 12
  • Unable to import floppyforms.gis, geometry widgets not available

    Unable to import floppyforms.gis, geometry widgets not available

    /home/foo/anaconda2/envs/flightsayer/lib/python2.7/site-packages/floppyforms/init.py:16: UserWarning: Unable to import floppyforms.gis, geometry widgets not available "Unable to import floppyforms.gis, geometry widgets not available")

    Ok, I get that this happens on "from . import gis", but I don't understand what's going on.

    (Everything worked fine until this morning, after I upgraded some stuff on my computer, and now I'm seeing this message and AHHHHH)

    opened by foobarbaz2 9
  • Allow override of template_name in __init__() and render().

    Allow override of template_name in __init__() and render().

    This fixes #89, allowing override of template_name in both __init__() (useful if you want to use the same widget class with two different templates without extra subclasses) and in render() (useful for more advanced use cases where you want to render the same widget instance on the same form field with two different templates, conditional on something).

    Tests are included and pass on a full tox run.

    I would happily add some docs as well, but in a quick perusal I didn't see where they would fit. As far as I can tell the individual widget classes are documented, but the core widget API isn't so far.

    opened by carljm 9
  • decimalfield should specify step=any

    decimalfield should specify step=any

    To avoid a validation error in chrome when entering decimals, the DecimalField template should specify

    <input type="number" step="any" />
    

    See: http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/

    What I have done so far is this:

    Added this to input.html:

    {% if attrs.decimal %}step="any"{% endif %}
    

    And created a new widget like this:

    class DecimalInput(floppyforms.widgets.NumberInput):
        def __init__(self, *args, **kwargs):
            kwargs['attrs'] = {'decimal':True}
            super(DecimalWidget, self).__init__(*args, **kwargs)
    
    Bug Needs patch plz! 
    opened by puterleat 9
  • Allow floppyforms to override default form widgets

    Allow floppyforms to override default form widgets

    Currently the documentation states "As for ModelForms, all the fields coming from the model still get a widget from django.forms and not from floppyforms, unless the widgets are overridden in the form’s Meta inner class." The reason for this is because Django has no officially sanctioned way for a form library to override this. The unofficial way would be to override the formfield_callback method but due to a quirk in Django's behavior, that gets lost in the inheritance chain.

    There has been some discussion of how to best achieve this but no decisions have been made yet. We want to pick an implementation that is along the design path of Django itself.

    opened by poswald 9
  • HTML5

    HTML5 "required" validation breaks formset empty forms.

    The empty forms on a formset may have multiple extra empty forms. If one of the extra forms remains empty, but has any "required" fields, browsers that support HTML5 pre-submit validation (like Chrome) will refuse to submit the formset (even though it would be valid according to Django's logic.)

    Django's admin doesn't have this problem because it just doesn't set the "required" attribute on any form fields. Maybe floppyforms should just do the same? Seems less complicated than the alternatives.

    opened by melinath 8
  • Bug fix: Input turns 1 to False

    Bug fix: Input turns 1 to False

    I have a Slider widget that was failing randomly. After spending several hours trying to find what was happening, I found that Input class turns True values into False. As you know, integer 1 equals to True in Python, therefore this code turns integers 1 into False. Thus my sliders where failing where value, min, max or step were equal to 1.

    I've created a test and commented the lines that were breaking my Sliders. Even though all tests pass, you might want to change the code for your checked stuff.

    One thing that I don't find very pythonic is the way True is checked:

    if value == True:
    

    Wouldn't it be better to do:

    if value:
    

    Cheers, Miguel

    opened by maraujop 8
  • Django 1.11 support

    Django 1.11 support

    This tries to pull in various 1.11 fixes into one place, as well as test 1.11 properly

    (This also reduces the scope of what the project tests to supported versions of Django)

    opened by rtpg 6
  • Implementation of DateInput widget should render hardcoded

    Implementation of DateInput widget should render hardcoded "%Y-%m-%d" format

    Implementation of DateInput widget should render hardcoded "%Y-%m-%d" format.

    1. In Django > 1.6 ISO formats are automatically appended to the list of input formats, unless they are not at first position. (see https://github.com/django/django/commit/90d3af380e8efec0301dd91600c6686232de3943)
    2. floppyforms DateInput and DateTimeInput both uses first available format which is often not required "%Y-%m-%d" format. (https://github.com/gregmuellegger/django-floppyforms/blob/master/floppyforms/widgets.py#L279)

    This renders date input as empty in browsers that support date html5 type, requiring user to enter date again:

    <input type="date" name="date_of_birth" value="10.07.2014" required="" class="dateinput form-control" id="id_date_of_birth">
    

    That in chrome renders as "dd/mm/yyyy" instead of "10/07/2014", client validation will not allow form to submit if it is required field and would set field to None if it is not required field, thus loosing information.

    I propose that DateInput widget always render value in rfc3339 format.

    Reference: https://github.com/gregmuellegger/django-floppyforms/issues/27

    opened by bmihelac 6
  • docs: Fix a few typos

    docs: Fix a few typos

    There are small typos in:

    • docs/customization.rst
    • docs/differences.rst
    • floppyforms/static/floppyforms/js/MapWidget.js

    Fixes:

    • Should read seamlessly rather than seemlesly.
    • Should read returned rather than returnes.
    • Should read attributes rather than attibutes.

    Semi-automated pull request generated by https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

    opened by timgates42 1
  • Jazzband: Synced file(s) with jazzband/.github

    Jazzband: Synced file(s) with jazzband/.github

    opened by jazzband-bot 1
  • set extent of map using map_options

    set extent of map using map_options

    i am trying to draw polygon on using floppy-form map in geodjango is there a way by which i can restrict user to draw polygon in certain restricted area using map_options

    in short i want to know how so i set map boundaries extent using JavaScript code for floppy form i know there is option for that in geodjango floppyform : "map_options"

    but i don't know how do i set that can someone help me ?

    opened by dhirajshinde121083 3
  • geodjango floppyform issue

    geodjango floppyform issue

    Hi i am new to geodjango floppyform, i have some difficulty i working on application where i need to restrict user to create point or line-string(route) withing certain geofence(city), so in short while user creating route map would allow to create point and linestring (route) in certain regien by keeping other part of map disabled ? e.g i want to make entry for bust stop as a point A but while creating i want to restrict user so that point should be created in "XYZ" city region of the map only, it should not allow user to create any entry out of the bbox of XYZ city, is it possible ? can someone please guide me ? my map contain 100 such cities

    opened by dhirajshinde121083 0
  • fetch for the issue 189. disable gis feature on settings.py

    fetch for the issue 189. disable gis feature on settings.py

    https://github.com/gregmuellegger/django-floppyforms/issues/189

    If don't want to use django's gis feature. Can disable to add FLOPPY_FORMS_USE_GIS = False option. It's simple fetch.

    opened by wapj 4
Tweak the form field rendering in templates, not in python-level form definitions. CSS classes and HTML attributes can be altered.

django-widget-tweaks Tweak the form field rendering in templates, not in python-level form definitions. Altering CSS classes and HTML attributes is su

Jazzband 1.8k Jan 2, 2023
Resolve form field arguments dynamically when a form is instantiated

django-forms-dynamic Resolve form field arguments dynamically when a form is instantiated, not when it's declared. Tested against Django 2.2, 3.2 and

DabApps 108 Jan 3, 2023
Use heroicons in your Django and Jinja templates.

heroicons Use heroicons in your Django and Jinja templates. Requirements Python 3.6 to 3.9 supported. Django 2.2 to 3.2 supported. Are your tests slow

Adam Johnson 52 Dec 14, 2022
This is a template tag project for django to calculate in templates , enjoy it

Calculator-Template-Django this is a template tag project for django to calculate in templates , enjoy it Get Started : 1 - Download Source Code 2 - M

null 1 Feb 1, 2022
A django model and form field for normalised phone numbers using python-phonenumbers

django-phonenumber-field A Django library which interfaces with python-phonenumbers to validate, pretty print and convert phone numbers. python-phonen

Stefan Foulis 1.3k Dec 31, 2022
MAC address Model Field & Form Field for Django apps

django-macaddress MAC Address model and form fields for Django We use netaddr to parse and validate the MAC address. The tests aren't complete yet. Pa

null 49 Sep 4, 2022
A django model and form field for normalised phone numbers using python-phonenumbers

django-phonenumber-field A Django library which interfaces with python-phonenumbers to validate, pretty print and convert phone numbers. python-phonen

Stefan Foulis 1.3k Dec 31, 2022
Twitter Bootstrap for Django Form

Django bootstrap form Twitter Bootstrap for Django Form. A simple Django template tag to work with Bootstrap Installation Install django-bootstrap-for

tzangms 557 Oct 19, 2022
Twitter Bootstrap for Django Form - A simple Django template tag to work with Bootstrap

Twitter Bootstrap for Django Form - A simple Django template tag to work with Bootstrap

tzangms 557 Oct 19, 2022
This is a sample Django Form.

Sample FORM Installation guide Clone repository git clone https://github.com/Ritabratadas343/SampleForm.git cd to repository. Create a virtualenv by f

Ritabrata Das 1 Nov 5, 2021
Basic Form Web Development using Python, Django and CSS

thebookrain Basic Form Web Development using Python, Django and CSS This is a basic project that contains two forms - borrow and donate. The form data

Ananya Dhulipala 1 Nov 27, 2021
Full featured redis cache backend for Django.

Redis cache backend for Django This is a Jazzband project. By contributing you agree to abide by the Contributor Code of Conduct and follow the guidel

Jazzband 2.5k Jan 3, 2023
Full-text multi-table search application for Django. Easy to install and use, with good performance.

django-watson django-watson is a fast multi-model full-text search plugin for Django. It is easy to install and use, and provides high quality search

Dave Hall 1.1k Dec 22, 2022
Dashboad Full Stack utilizando o Django.

Dashboard FullStack completa Projeto finalizado | Informações Cadastro de cliente Menu interatico mostrando quantidade de pessoas bloqueadas, liberada

Lucas Silva 1 Dec 15, 2021
Full-featured django project start tool.

django-start-tool Introduction django-start-tool is a full-featured replacement for django-admin startproject which provides cli for creating the same

Georgy Gnezdilov 0 Aug 30, 2022
Wagtail - Vue - Django : The initial environment of full-stack local dev web app with wagtail and vue

Wagtail - Vue - Django : The initial environment of full-stack local dev web app with wagtail and vue. A demo to show how to use .vue files inside django app.

Quang PHAM 2 Oct 20, 2022
TinyApp - A Python (Django) Full Stack Application for shortening URLs

TinyApp A Python (Django) Full Stack Application for shortening URLs. How to sta

Li Deng 1 Jan 23, 2022
django-reversion is an extension to the Django web framework that provides version control for model instances.

django-reversion django-reversion is an extension to the Django web framework that provides version control for model instances. Requirements Python 3

Dave Hall 2.8k Jan 2, 2023
The best way to have DRY Django forms. The app provides a tag and filter that lets you quickly render forms in a div format while providing an enormous amount of capability to configure and control the rendered HTML.

django-crispy-forms The best way to have Django DRY forms. Build programmatic reusable layouts out of components, having full control of the rendered

null 4.6k Jan 7, 2023