#27311: Assigning ForeignKey fields in migrations
-------------------------------------+-------------------------------------
     Reporter:  Odero                |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Migrations           |                  Version:  1.10
     Severity:  Normal               |               Resolution:
     Keywords:  migrations,          |             Triage Stage:
  foreignkey                         |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Odero):

 I meant automatic caching. I have set up `django-cacheops` to auto-manage
 the caching for me. BUT, even without cacheops, just manual caching also
 causes the error. Here's a contrived example to illustrate this effect and
 which fails when using cached data.

 {{{
 def generate_invoices(apps, schema_editor):
     A = apps.get_model('app1', 'A')
     B = apps.get_model('app1', 'B')
     User = apps.get_model('accounts', 'User')

     for item in A.objects.all():
         u = User.objects.get(pk=item.user.pk)

         # Simulate fetching cached data
         # start caching-segment
         cache.set('user', u)
         u = cache.get('user')
         # end caching-segment

         b = B(client=u, status=1)
         b.save()

 }}}

 If I remove those 2 lines in the "caching-segment", thereby eliminating
 caching, the migration runs successfully.

--
Ticket URL: <https://code.djangoproject.com/ticket/27311#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.583f53b8ae6be6e1ed18ff3081652638%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to