Commit ab21927a authored by Dirk Wallenstein's avatar Dirk Wallenstein Committed by Jeremy Kerr
Browse files

models: Don't require optional model fields in forms



Add blank = True for nullable fields, to allow forms to be subitted
without a value for these fields.

The keyword 'blank' concerns only validation and does not change what
will be stored in the database.
Signed-off-by: default avatarDirk Wallenstein <halsmit@t-online.de>
Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
parent 47c56dfa
...@@ -44,8 +44,8 @@ except ImportError: ...@@ -44,8 +44,8 @@ except ImportError:
class Person(models.Model): class Person(models.Model):
email = models.CharField(max_length=255, unique = True) email = models.CharField(max_length=255, unique = True)
name = models.CharField(max_length=255, null = True) name = models.CharField(max_length=255, null = True, blank = True)
user = models.ForeignKey(User, null = True) user = models.ForeignKey(User, null = True, blank = True)
def __unicode__(self): def __unicode__(self):
if self.name: if self.name:
...@@ -71,7 +71,7 @@ class Project(models.Model): ...@@ -71,7 +71,7 @@ class Project(models.Model):
class UserProfile(models.Model): class UserProfile(models.Model):
user = models.ForeignKey(User, unique = True) user = models.ForeignKey(User, unique = True)
primary_project = models.ForeignKey(Project, null = True) primary_project = models.ForeignKey(Project, null = True, blank = True)
maintainer_projects = models.ManyToManyField(Project, maintainer_projects = models.ManyToManyField(Project,
related_name = 'maintainer_project') related_name = 'maintainer_project')
send_email = models.BooleanField(default = False, send_email = models.BooleanField(default = False,
...@@ -188,10 +188,10 @@ class Patch(models.Model): ...@@ -188,10 +188,10 @@ class Patch(models.Model):
state = models.ForeignKey(State) state = models.ForeignKey(State)
archived = models.BooleanField(default = False) archived = models.BooleanField(default = False)
headers = models.TextField(blank = True) headers = models.TextField(blank = True)
content = models.TextField(null = True) content = models.TextField(null = True, blank = True)
pull_url = models.CharField(max_length=255, null = True) pull_url = models.CharField(max_length=255, null = True, blank = True)
commit_ref = models.CharField(max_length=255, null = True, blank = True) commit_ref = models.CharField(max_length=255, null = True, blank = True)
hash = HashField(null = True, db_index = True) hash = HashField(null = True, blank = True)
def __unicode__(self): def __unicode__(self):
return self.name return self.name
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment