﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24495	Allow unsaved objects in ForeignKey check to be bypassed	Karl Hobley	nobody	"Hi everyone,

https://code.djangoproject.com/ticket/10811 implements a new check to prevent unsaved objects being set on a ForeignKey field.

A project I'm upgrading to Django 1.8 (Wagtail CMS/django-modelcluster) relies on this behaviour (for generating previews of pages without having to save them to the database. Pages can have other unsaved objects such as links or images linked to them).

See: https://github.com/torchbox/django-modelcluster#django-modelcluster

Unfortunately, this isn't an easy problem to solve without a small change to Django....


== Proposed solution ==

Allow a flag to be specified on a subclass of ForeignKey which allows this check to be bypassed.

PR: https://github.com/django/django/pull/4334

django-modelcluster uses a subclass of ForeignKey called ""ParentalKey"". In Wagtail, all of the ""child models"" (eg, page links, images, etc) are linked to their Page model using a ParentalKey.

Setting this flag on the ParentalKey class fixes this issue: https://github.com/kaedroho/django-modelcluster/commit/915dc7e1cfc2462c2068ab9e9a334a7197935c7d"	Uncategorized	new	Database layer (models, ORM)	1.8beta2	Normal				Unreviewed	1	0	0	0	0	0
