Skip to content

Commit

Permalink
Merge pull request #689 from dudanogueira/master
Browse files Browse the repository at this point in the history
RandomCharField: lowercase=False fully working plus populate blank fields
  • Loading branch information
trbs committed Jun 10, 2015
2 parents dadf3c8 + 703e6a1 commit c72d0e3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions django_extensions/db/fields/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,15 @@ def random_char_generator(self, chars):
MAX_UNIQUE_QUERY_ATTEMPTS)

def pre_save(self, model_instance, add):
if not add:
if not add and getattr(model_instance, self.attname) != '':
return getattr(model_instance, self.attname)

population = ''
if self.include_alpha:
if self.lowercase:
population += string.ascii_lowercase
else:
population += string.ascii_letters
population += string.ascii_uppercase

if self.include_digits:
population += string.digits
Expand Down

0 comments on commit c72d0e3

Please sign in to comment.