Skip to main content

Spectre CSS for Django

Project description

django-spectre-css

This Module uses spectre.css (https://picturepan2.github.io/spectre/) to style a Django application.

Installation

Install:

pip install django-spectre-css

To use include static/css/lib/\*.css in your base templates css files or in your CSS pipeline

add it to your installed apps:

INSTALLED_APPS = [
    '...',
    'django_spectre_css',
    'widget_tweaks',
]

Warning

The help_text from models is marked as save in the template and therefore it is possible to have html e.g. links in the help_text. This means that help_text of an ModelField should never be directly based on user input.

Examples:

This module defines the following tags to make displaying forms easier.

  • render the form header (csrf-token and non-field errors) for the form 'form':

    {% load spectre_css %}

    {% render_form_header form %} [...]
  • render a field user of the form 'form':

    {% extends base.html %} {% load spectre_css %}

    [...] {% render_form_field form.user %}

  • render the whole form:

    {% extends base.html %} {% load spectre_css %}

    {% render_form form %}
  • render the first two parts of a MultiValueField as independent Fields:

    {% extends base.html %} {% load spectre_css %}

    [...] {% render_form_field form.datetime 0 label_text="Date"%} {% render_form_field form.datetime 1 label_text="Time" %}

render_form_field takes the following keyword arguments:

  • switch=True|False for checkboxes, if True renders the checkbox as switch
  • add_choices=[(value,text),...] to add the choices of an select to the select
  • replace_choices=[(value,text),...] to set the choices of an select manually
  • empty_option=value to generate an empty option if None is selected with the text value (only select widgets)
  • value=value overwrites the initial value of the field (not Checkbox and Select) with value

Upgrades

From < 0.3

'django-spectre-css' has to be changed into 'django_spectre_css' in th INSTALLED_APPS in Django settings.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-spectre-css-0.3.dev1.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

django_spectre_css-0.3.dev1-py3-none-any.whl (55.5 kB view details)

Uploaded Python 3

File details

Details for the file django-spectre-css-0.3.dev1.tar.gz.

File metadata

  • Download URL: django-spectre-css-0.3.dev1.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for django-spectre-css-0.3.dev1.tar.gz
Algorithm Hash digest
SHA256 47a046071d6cb67f1aacacbc635ca9daa19efdb4638eac208686a1c2656e4ac9
MD5 50e76766761df6cb9300f2e04fbc2368
BLAKE2b-256 345fe8b93f1be5d0edb5d87892d496af5881f2ca81e542b0fccb71d2390eb26b

See more details on using hashes here.

File details

Details for the file django_spectre_css-0.3.dev1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_spectre_css-0.3.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 d117f4add2a3b09a26d6982652ad537a592929e5bd79f44814df237134275cc9
MD5 e4d4dbd2930447ddb54836ca068318ac
BLAKE2b-256 90a10118410ef98af0385648ec525cb72958c85a653421c0d753ba534d9d33fe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page