File: models.py

package info (click to toggle)
python-django-colorfield 0.11.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 368 kB
  • sloc: javascript: 2,510; python: 716; makefile: 14; sh: 2
file content (96 lines) | stat: -rw-r--r-- 2,102 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from django.db import models

from colorfield.fields import ColorField

COLOR_PALETTE = [
    ("#FFFFFF", "white"),
    ("#000000", "black"),
]


class Color(models.Model):
    color = ColorField(blank=True)

    class Meta:
        app_label = "tests"


class ColorNull(models.Model):
    color = ColorField(null=True)

    class Meta:
        app_label = "tests"


class ColorChoices(models.Model):
    COLOR_CHOICES = COLOR_PALETTE

    color = ColorField(blank=True, choices=COLOR_CHOICES)

    class Meta:
        app_label = "tests"


class ColorSamples(models.Model):
    COLOR_SAMPLES = COLOR_PALETTE

    color = ColorField(blank=True, samples=COLOR_SAMPLES)

    class Meta:
        app_label = "tests"


class ColorNoImageField(models.Model):
    color = ColorField(image_field="image")

    class Meta:
        app_label = "tests"


class ColorInvalidImageField(models.Model):
    image = models.CharField(blank=True, max_length=10)
    color = ColorField(image_field="image")

    class Meta:
        app_label = "tests"


class ColorImageField(models.Model):
    image = models.ImageField(blank=True, upload_to="temp")
    color = ColorField(image_field="image")

    class Meta:
        app_label = "tests"


class ColorImageFieldAndDefault(models.Model):
    image = models.ImageField(blank=True, upload_to="temp")
    color = ColorField(image_field="image", default="#FF0000")

    class Meta:
        app_label = "tests"


class ColorImageFieldAndFormat(models.Model):
    image = models.ImageField(blank=True, upload_to="temp")
    color = ColorField(image_field="image", format="hexa")

    class Meta:
        app_label = "tests"


class ColorFieldRGBFormat(models.Model):
    color_rgb = ColorField(format="rgb")
    color_rgba = ColorField(format="rgba")

    class Meta:
        app_label = "tests"


class ColorImageFieldRGBFormat(models.Model):
    image = models.ImageField(blank=True, upload_to="temp")
    color_rgb = ColorField(image_field="image", format="rgb")
    color_rgba = ColorField(image_field="image", format="rgba")

    class Meta:
        app_label = "tests"