File: models.py

package info (click to toggle)
django-bleach 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 448 kB
  • sloc: python: 1,155; makefile: 137; sh: 16
file content (19 lines) | stat: -rw-r--r-- 562 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from django.db import models

from bleach.css_sanitizer import CSSSanitizer

from django_bleach.models import BleachField


class Person(models.Model):
    name = models.CharField(max_length=20)
    biography = BleachField(
        max_length=100,
        verbose_name="Person biography",
        allowed_tags=["p", "a", "li", "ul", "strong"],
        allowed_attributes=["class", "href", "style"],
        allowed_protocols=["http", "https"],
        css_sanitizer=CSSSanitizer(
            allowed_css_properties=["color", "background-color"]
        ),
    )