Code Monkey home page Code Monkey logo

Comments (6)

jwalgran avatar jwalgran commented on July 27, 2024

Crispy has been talked about before, and it explicitly calls out Bootstrap 3 in the readme. I would vote for trying crispy.

from nyc-trees.

RickMohr avatar RickMohr commented on July 27, 2024

I suspect (and Steve's experience seems to show) that {{ form.as_p }} and friends are too brittle and you need to unroll field refs in your templates. Django forms give you plenty beyond that.

Do you know whether any of the alternatives address your other issues?

Looks like a big part of Crispy Forms is doing layout in the Python code. While that might be somewhat more concise I'd rather stick with HTML templates to facilitate working with the design team.

from nyc-trees.

maurizi avatar maurizi commented on July 27, 2024

I'd be most inclined to give floppy forms a shot if we're going to stick with doing all of our layouts in templates, it looks like they tackle some of the client-side HTML5 validation I mentioned (see http://django-floppyforms.readthedocs.org/en/latest/differences.html).

It looks like the main benefits of Crispy are more powerful control of layout in Python, but I don't see anything in the docs about using HTML5 input attributes.

from nyc-trees.

steventlamb avatar steventlamb commented on July 27, 2024

My experience has been that {{ form.as_<...> }} breaks down in all cases beyond simple prototyping. I am skeptical that generated markup provided by another library would yield different results.

The next step further in granularity is to break the form down further:
https://github.com/vegphilly/vegphilly.com/blob/master/vegancity/templates/vegancity/new_vendor.html

Which renders to stuff like

<div class="fieldWrapper">

          <label for="id_name">Name

          </label>

          <input id="id_name" maxlength="255" name="name" type="text">

        </div>

This is not a huge improvement, because there is still a fair amount of markup generation. DOM id and class attributes are still created by django, and you end up with different sets of naming conventions in your CSS, (some for attributes you write yourself, different for the generated ones).

This, as I see it, is the core problem:

  1. missing HTML5 attributes
  2. non-semantic dom attributes
  3. Weird Spacing

I don't know if this can be done better with vanilla django forms, and I obviously don't know if it's any different in these 3rd-party libs.

I think they all support a concept of widgets, which allows you to customize how markup is generated. My inkling is that this would be painful. I don't love writing new classes for a problem that can be solved declaratively in HTML.

from nyc-trees.

steventlamb avatar steventlamb commented on July 27, 2024

In conclusion, my vote is that we stick with django forms and write our own markup. That said, I think whichever of the 3 discussed solutions (vanilla, floppy, crispy) will be fine. The only risk is bringing in a library that doesn't get you much.

from nyc-trees.

maurizi avatar maurizi commented on July 27, 2024

We went with floppyforms

from nyc-trees.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.