Changes between Initial Version and Version 1 of Ticket #27168, comment 3


Ignore:
Timestamp:
Sep 6, 2016, 9:57:15 AM (8 years ago)
Author:
John

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #27168, comment 3

    initial v1  
    1 The original code is this:
     1The original code (changed some of the code) is this:
    22
    33{{{
    4 def migrate_client_billing(apps, schema_editor):
    5     engagement_client_model = apps.get_model(
    6         app_label='engagement',
    7         model_name='EngagementClient')
     4def migrate_xxxxx(apps, schema_editor):
     5    my_model_model = apps.get_model(
     6        app_label='myapp',
     7        model_name='MyModel')
    88
    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')
    1212
    13     engagement_clients = engagement_client_model.objects.all()
     13    my_objects = my_model_model.objects.all()
    1414
    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.client
     15    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
    1919        )
    2020}}}
     
    3131Running migrations:
    3232  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):
    3434  File "manage.py", line 12, in <module>
    3535    execute_from_command_line(sys.argv)
     
    5252  File "/home/user/project101/lib/python2.7/site-packages/django/db/migrations/operations/special.py", line 183, in database_forwards
    5353    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_billing
     54  File "/home/user/project101/project/billing/migrations/0003_create_missing_xxxxx.py", line 15, in migrate_client_billing
    5555    model_name='EngagementClient')
    5656  File "/home/user/project101/lib/python2.7/site-packages/django/apps/registry.py", line 202, in get_model
     
    5858  File "/home/user/project101/lib/python2.7/site-packages/django/apps/config.py", line 162, in get_model
    5959    "App '%s' doesn't have a '%s' model." % (self.label, model_name))
    60 LookupError: App 'engagement' doesn't have a 'engagementclient' model.
     60LookupError: App 'myapp' doesn't have a 'mymodel' model.
    6161}}}
Back to Top