Here is my model.
Poll(models.Model):
title = models.CharField(max_length=1024)
MY_VAR = ['my_class_level_attribute'] # I want to access this
Here is my data migration:
def my_func(apps, schema_editor):
Poll = apps.get_model('my_app', 'Poll')
print Poll.MY_VAR
class Migration(migrations.Migration):
dependencies = [
('webmerge', '0012_previous_migration'),
]
operations = [
migrations.RunPython(my_func)
]
The line print Poll.MY_VAR
gives an attribute error. I think the issue might is in how get_model
performs within a data migration because the following lines succeed in a Django shell:
In [2]: from django.apps import apps
In [3]: Poll = apps.get_model('my_app', 'Poll')
In [4]: Poll.MY_VAR
Out[4]: ['my_class_level_attribute']
The lesson learned was that the test data must be random and should have sufficient breadth. I also believe that the data migration process should be executed as a Financial System where at every step the auditors can audit. What I mean here is several levels of reconciliation should happen as a part of the plan.
A single data migration process can involve different types, including: 1. Storage Migration Storage migration is where a business migrates data from one storage location to another. It means moving data from one physical medium to another.
The movement is not driven by a lack of space but rather a desire to upgrade storage technology. It normally does not alter the content or format of data. During storage migration, certain steps such as data validation, cloning, and data cleaning and redundancy can be carried out.
I also believe that the data migration process should be executed as a Financial System where at every step the auditors can audit. What I mean here is several levels of reconciliation should happen as a part of the plan. The first level of recon should be a simple sum of a numeric field, a number of rows, minimum/maximum of a date field etc.
You should be able to import the model
from my_app.models import Poll
If you do this, you shouldn't delete the Poll
model or the MY_VAR
attribute, otherwise your migrations will stop working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With