4 ms·
Earle/django-bootstrap - GitHub
- andr 15y agoGreat 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.
- StavrosK 15y agoCould you paste some sample code? Is it worth using Jinja over Django's templates?
- earle 15y agoThe 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.
- po 15y agoHa, 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 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.
- huxley 15y agoOne 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/ https://github.com/maraujop/django-crispy-forms/ [2] https://github.com/maraujop/django-crispy-forms/issues/5 https://github.com/maraujop/django-crispy-forms/issues/5
- lukeman 15y agoWe'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/ http://github.com/pinax/pinax-theme-bootstrap/
- joelhaasnoot 15y agoI 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.
- aiurtourist 15y agoThis 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 https://github.com/miracle2k/webassets) for building asset bundles.
- nulluk 15y agoWe 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 https://github.com/theorm/django-bootstrap-forms
- StavrosK 15y agoMy 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.
- earle 15y agoSee above