added CachedForeignKey for photo and type of attachment