Hacker News new | past | comments | ask | show | jobs | submit login
Earle/django-bootstrap - GitHub (github.com/earle)
72 points by superchink on Feb 5, 2012 | hide | past | favorite | 13 comments



Great to have this, but I very much dislike the idea of changing the base Form classes just to get a different rendering.

What I've been doing in Django is using Jinja template macros to create my own rendering for the standard form classes. Not ideal, but sticks to the idea of separation of logic and presentation.


The template tags and filters will certainly solve most use cases, but there are specific reasons why Django implements Forms outside of the template -- there will be significant functionality you cant (and shouldnt) achieve through a template.

This is why the base Form was extended. To each their own.


Could you paste some sample code? Is it worth using Jinja over Django's templates?


We're doing something far more comprehensive with the Bootstrap theme for Pinax and if not for a few things you don't even really need Pinax and can just use Django with our theme app: http://github.com/pinax/pinax-theme-bootstrap/


I've been using this with great results on an intranet project. It's allowed me to have a professional looking site without having to put much thought into design & layout. Thanks so much!


+1


Ha, I was just looking into something like this.

Interestingly one approach is to use the django uni-form project with the {% form|as_uni_form %} filter. You can then output whatever HTML you want. The https://github.com/kennethlove/django-uni-form-contrib project provides a good starting point for templates compatible with the bootstrap project but looking at it, there's still a lot to be desired and it looks somewhat inactive.


One factor might be that django uni-form is being replaced with django-crispy-forms[1], some functionality of django uni-form contrib is begin rolled into django crispy forms.[2]

[1] https://github.com/maraujop/django-crispy-forms/

[2] https://github.com/maraujop/django-crispy-forms/issues/5


We have been including a similar thing in our project base for some time and have been through quite a few iterations & ways to implement something like this. Thus far we are using something very similar: https://github.com/theorm/django-bootstrap-forms


This is a great project that helps to bring a more "hip" feel to Django development.

FWIW, if you're working with a lot of CSS and JavaScript resources, check out webassets (https://github.com/miracle2k/webassets) for building asset bundles.


My alternative to this was to write an inclusion template tag. This separates logic from presentation more cleanly, and it allows forms where, for example, first name and last name fields take up half of the space of the same row, and the rest of the fields are on full rows.


See above


I use django-uni-form all the time in my projects but use the helper syntax. By having a form helper you can completely customize every aspect of your form.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: