From 703e6a16c3b99e9bf3717213ab54c09af6fd0b72 Mon Sep 17 00:00:00 2001 From: Eduardo Nogueira Date: Wed, 10 Jun 2015 09:01:03 -0300 Subject: [PATCH] RandomCharField: lowercase=False now only gets uppercase letters. Also, if the field is blank, it will also be populated on the pre_save method --- django_extensions/db/fields/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django_extensions/db/fields/__init__.py b/django_extensions/db/fields/__init__.py index a644d40a2..410e44fb2 100644 --- a/django_extensions/db/fields/__init__.py +++ b/django_extensions/db/fields/__init__.py @@ -266,7 +266,7 @@ 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 = '' @@ -274,7 +274,7 @@ def pre_save(self, model_instance, add): if self.lowercase: population += string.ascii_lowercase else: - population += string.ascii_letters + population += string.ascii_uppercase if self.include_digits: population += string.digits