danfairs/django-dfk — pull request #1 by mhsparks (2012-07-11 11:01:21+00:00)
Title: Added clean_caches option to point and repoint

When you have a minute please could you take a quick look. From the docs I updated:

Pointing or repointing foreign keys requires that related object caches are
repopulated as relationships will have changed and things like filtering on
related objects are likely to fail.

For apps with many DeferredForeignKey instances involving the same model
it may be more efficient to clean the caches once after all pointing and
repointing has finished rather than after every point or repoint. To
enable this pass clean_caches=False to point or repoint

from dfk import point
from mycomments.models import Comment

class BlogPost(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField()
body = models.TextField()

point(Comment, 'content', BlogPost, clean_caches=False)

for opts in Comment._meta, BlogPost._meta:
opts._fill_related_objects_cache()
opts.init_name_map()