Changes between Initial Version and Version 1 of Ticket #27168, comment 3
- Timestamp:
- Sep 6, 2016, 9:57:15 AM (8 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #27168, comment 3
initial v1 1 The original code is this:1 The original code (changed some of the code) is this: 2 2 3 3 {{{ 4 def migrate_ client_billing(apps, schema_editor):5 engagement_client_model = apps.get_model(6 app_label=' engagement',7 model_name=' EngagementClient')4 def migrate_xxxxx(apps, schema_editor): 5 my_model_model = apps.get_model( 6 app_label='myapp', 7 model_name='MyModel') 8 8 9 client_billing_model = apps.get_model(10 app_label=' billing',11 model_name=' ClientBilling')9 my_other_model_model = apps.get_model( 10 app_label='myotherapp', 11 model_name='MyOtherModel') 12 12 13 engagement_clients = engagement_client_model.objects.all()13 my_objects = my_model_model.objects.all() 14 14 15 for engagement_client in engagement_clients:16 obj, created = client_billing_model.objects.get_or_create(17 engagement= engagement_client.engagement,18 client= engagement_client.client15 for my_object in my_objects: 16 obj, created = my_other_model_model.objects.get_or_create( 17 engagement=my_object.engagement, 18 client=my_object.client 19 19 ) 20 20 }}} … … 31 31 Running migrations: 32 32 Rendering model states... DONE 33 Applying billing.0003_create_missing_ client_billing...Traceback (most recent call last):33 Applying billing.0003_create_missing_xxxxx...Traceback (most recent call last): 34 34 File "manage.py", line 12, in <module> 35 35 execute_from_command_line(sys.argv) … … 52 52 File "/home/user/project101/lib/python2.7/site-packages/django/db/migrations/operations/special.py", line 183, in database_forwards 53 53 self.code(from_state.apps, schema_editor) 54 File "/home/user/project101/project/billing/migrations/0003_create_missing_ client_billing.py", line 15, in migrate_client_billing54 File "/home/user/project101/project/billing/migrations/0003_create_missing_xxxxx.py", line 15, in migrate_client_billing 55 55 model_name='EngagementClient') 56 56 File "/home/user/project101/lib/python2.7/site-packages/django/apps/registry.py", line 202, in get_model … … 58 58 File "/home/user/project101/lib/python2.7/site-packages/django/apps/config.py", line 162, in get_model 59 59 "App '%s' doesn't have a '%s' model." % (self.label, model_name)) 60 LookupError: App ' engagement' doesn't have a 'engagementclient' model.60 LookupError: App 'myapp' doesn't have a 'mymodel' model. 61 61 }}}