Skip to content

Commit 7e4c1e7

Browse files
authored
Merge pull request #200 from novafloss/unicode-compatible-models
Define __unicode__ and __str__ on models
2 parents b7e8be1 + a367481 commit 7e4c1e7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

formidable/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
from django.core.exceptions import ValidationError
66
from django.db import models
7+
from django.utils.encoding import python_2_unicode_compatible
78

89
from formidable import constants
910
from formidable.register import FieldSerializerRegister
1011

1112

13+
@python_2_unicode_compatible
1214
class Formidable(models.Model):
1315

1416
label = models.CharField(max_length=256)
@@ -58,6 +60,7 @@ def __str__(self):
5860
return '{formidable.label}'.format(formidable=self)
5961

6062

63+
@python_2_unicode_compatible
6164
class Field(models.Model):
6265

6366
class Meta:
@@ -87,6 +90,7 @@ def __str__(self):
8790
return '{field.label}'.format(field=self)
8891

8992

93+
@python_2_unicode_compatible
9094
class Default(models.Model):
9195

9296
value = models.CharField(max_length=256)
@@ -96,6 +100,7 @@ def __str__(self):
96100
return '{default.value}'.format(default=self)
97101

98102

103+
@python_2_unicode_compatible
99104
class Item(models.Model):
100105
field = models.ForeignKey(Field, related_name='items')
101106
value = models.CharField(max_length=256)
@@ -107,6 +112,7 @@ def __str__(self):
107112
return '{item.label}: {item.value}'.format(item=self)
108113

109114

115+
@python_2_unicode_compatible
110116
class Access(models.Model):
111117

112118
class Meta:
@@ -124,6 +130,7 @@ def __str__(self):
124130
access=self)
125131

126132

133+
@python_2_unicode_compatible
127134
class Validation(models.Model):
128135
field = models.ForeignKey(Field, related_name='validations')
129136
value = models.CharField(max_length=256)
@@ -135,6 +142,7 @@ def __str__(self):
135142
validation=self)
136143

137144

145+
@python_2_unicode_compatible
138146
class Preset(models.Model):
139147
form = models.ForeignKey(Formidable, related_name='presets')
140148
slug = models.CharField(max_length=128)
@@ -144,6 +152,7 @@ def __str__(self):
144152
return '{preset.slug}'.format(preset=self)
145153

146154

155+
@python_2_unicode_compatible
147156
class PresetArg(models.Model):
148157
preset = models.ForeignKey(Preset, related_name='arguments')
149158
slug = models.CharField(max_length=128)

0 commit comments

Comments
 (0)