i use Django 1.9.2 with python 3.4.2.
In the first half of the development lifecycle i had this code:
class ModificationOrder(ERN):
...
san_amount = models.IntegerField(default=0, \
validators=[validate_modificationorder_san_amount])
, and i created an initial migration which resulted this line in the 0001_initial.py file:
migrations.CreateModel(
...
fields = [
...
('san_amount', models.IntegerField(default=0, validators=[shop.validators.validate_modificationorder_san_amount])),
])
. Later i had a few migrations and i deleted the san_amount field from the model, but probably that is not related to my problem.
Now i tried to change the name of the validator to validate_resource_san_amount, but after changing it runserver results this error:
python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f8ec1a5a510>
Traceback (most recent call last):
File "/home/csa.virtualenvs/sccdb34/lib/python3.4/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/csa/.virtualenvs/sccdb34/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check_migrations()
File "/home/csa/.virtualenvs/sccdb34/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 163, in check_migrations
executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
File "/home/csa/.virtualenvs/sccdb34/lib/python3.4/site-packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/csa/.virtualenvs/sccdb34/lib/python3.4/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/home/csa/.virtualenvs/sccdb34/lib/python3.4/site-packages/django/db/migrations/loader.py", line 170, in build_graph
self.load_disk()
File "/home/csa/.virtualenvs/sccdb34/lib/python3.4/site-packages/django/db/migrations/loader.py", line 105, in load_disk
migration_module = import_module("%s.%s" % (module_name, migration_name))
File "/home/csa/.virtualenvs/sccdb34/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/csa/git/sccdb/sccdb/shop/migrations/0001_initial.py", line 12, in <module>
class Migration(migrations.Migration):
File "/home/csa/git/sccdb/sccdb/shop/migrations/0001_initial.py", line 226, in Migration
('san_amount', models.IntegerField(default=0, validators=[shop.validators.validate_modificationorder_san_amount])),
AttributeError: 'module' object has no attribute 'validate_modificationorder_san_amount'
.
To solve the problem i guess it' d be enough to change all validate_modificationorder_san_amount to validate_resource_san_amount, but i guess conceptionally it' s a bad idea. How should i handle this problem in the right way? - So to change a validator name which is already in a migration file.