Bulma CSS Framework for Django projects
Project description
Fork of Django Bulma (timonweb)
This fork moves more functionality into the templates, instead of adding CSS in python code.
It is also more extensible, since templates can be included and blocks can be overriden.
For the added functionality, look at section New Additions
A Bulma Theme for Django Projects
A Django base theme based on Bulma (bulma.io). Bulma is a modern CSS framework based on Flexbox.
*** work in progress ***
Installation
- Install the python package django-bulma from pip
pip install django-bulma
Alternatively, you can install download or clone this repo and call pip install -e .
.
- Add to INSTALLED_APPS in your settings.py:
'bulma',
- If you want to use the provided base template, extend from bulma/base.html:
{% extends 'bulma/base.html' %}
{% block title %}Bulma Site{% endblock %}
{% block content %}
Content goes here...
{% endblock content %}
-
If you want to customize bulma sass and your own components:
4.1 Copy bulma static files into your project's STATIC_ROOT:
python manage.py copy_bulma_static_into_project
You should see bulma dir appeared in your STATIC_ROOT. It contains two dirs:
- sass - this is the place where you can put your own sass code and customize bulma variables
- css - this is where compiled sass output goes, you should link this file in your base.html
4.2 Install npm packages for sass compilation to work:
python manage.py bulma install
4.3 Start sass watch mode:
python manage.py bulma start
-
For forms, in your templates, load the
bulma_tags
library and use the|bulma
filters:Example template
{% load bulma_tags %} {# Display a form #} <form action="/url/to/submit/" method="post"> {% csrf_token %} {{ form|bulma }} <div class="field"> <button type="submit" class="button is-primary">Login</button> </div> <input type="hidden" name="next" value="{{ next }}"/> </form>
Included templates
django-bulma comes with:
- a base template,
- django core registration templates,
Bugs and suggestions
If you have found a bug or if you have a request for additional functionality, please use the issue tracker on GitHub.
https://github.com/nkay08/django-bulma/issues
New Additions
The form and fields can be rendered in exactly the same way as before. However, fields can now also be used by simply including a template.
Templates
bulma/forms/field.html
: The basic field template that is included by django-bulma'sform.html
bulma/forms/field_include.html
: Can be included directly with awith field=form.<your_field>
statement. Does NOT add markup classes, but they can be provided manually.bulma/forms/bulma_field_include.html
: Can be included directly with awith field=form.<your_field>
statement, and adds markup classes like thebulma
template filterbulma/forms/bulma_inline_field_include.html
: Can be included directly with awith field=form.<your_field>
statement, and adds markup classes like thebulma_inline
template filterbulma/forms/bulma_horizontal_field_include.html
: Can be included directly with awith field=form.<your_field>
statement, and adds markup classes like thebulma_horizontal
template filter
You can customize the fields, e.g. by extending bulma/forms/field_include.html
and overriding its blocks and then changing the respective setting.
Settings
You can specify which templates django-bulma
uses for rendering forms and fields, and thus allow extensibility and customization.
These affect django-bulma
's rendering template filters, but also all field templates that are prefixed with bulma_
.
Options for settings.py
:
BULMA_FIELD_TEMPLATE
: Specifies which field template is used by bulma rendering. Default"bulma/forms/field_include.html"
.BULMA_FIELD_WRAPPER_TEMPLATE
: Specifies which field wrapper template is used by bulma rendering. This wrapper coverts some context dicts to flat variables. Default"bulma/forms/field.html"
.BULMA_FORM_TEMPLATE
: Specifies which form template is used by bulma rendering. Default"bulma/forms/form.html"
.BULMA_FORMSET_TEMPLATE
: Specifies which formset template is used by bulma rendering. Default"bulma/forms/formset.html"
.
Bulma CSS
- Inline icons: You can now generate inputs that have inline icons
- Add
has-icons-left
orhas-icons-right
or both asclasses_value
when including or providing them as parameter when using thebulma
template tag - You can specify the icon css class with the context
icon_left_class
andicon_right_class
(currently only possible when including template)
- Add
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-bulma-form-templates-0.8.4.tar.gz
.
File metadata
- Download URL: django-bulma-form-templates-0.8.4.tar.gz
- Upload date:
- Size: 128.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.6.13 Linux/5.4.0-1047-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ef261a24f1c1f3c1e64b21458ed6243583d0380d6ef695d5592005a0d6f27a6 |
|
MD5 | 00073e0f96e93b8c51a6de09542483c9 |
|
BLAKE2b-256 | 2d1e8485d1be9eb06aa6dadd0a5564170e9b191667b173a33dd11ad2291e60af |
File details
Details for the file django_bulma_form_templates-0.8.4-py3-none-any.whl
.
File metadata
- Download URL: django_bulma_form_templates-0.8.4-py3-none-any.whl
- Upload date:
- Size: 139.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.6.13 Linux/5.4.0-1047-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a421310e85f307f9392cdf8d812a1249efcaa58d85c522befa4ae27d290b7397 |
|
MD5 | 3c83695bcbab72cfdf35aa92b89aaae8 |
|
BLAKE2b-256 | 823321e8cd1b39220473c1ccff590648150aadf109eec5efce6777fda64734c6 |