Skip to content

Commit

Permalink
Added Attribute.required
Browse files Browse the repository at this point in the history
  • Loading branch information
jpic committed Sep 13, 2012
1 parent 708bac5 commit fd3660c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion not_eav/models.py
Expand Up @@ -30,6 +30,7 @@ class Attribute(models.Model):

verbose_name = models.CharField(max_length=100, null=True, blank=True)
help_text = models.TextField(blank=True)
required = models.BooleanField(default=False)
kind = models.CharField(max_length=70, choices=KIND_CHOICES)

@classmethod
Expand All @@ -46,7 +47,11 @@ def field_instance(self):

@property
def field_kwargs(self):
kwargs = dict(null=True, blank=True)
kwargs = {}
if self.required:
kwargs['null'] = kwargs['blank'] = False
else:
kwargs['null'] = kwargs['blank'] = True

if self.verbose_name:
kwargs['verbose_name'] = self.verbose_name
Expand Down

0 comments on commit fd3660c

Please sign in to comment.