﻿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
24325	Cannot reference FK relation from inline ModelForm.save()	Stanislas Guerra	Tim Graham	"Hi devs,

Not sure that's a bug but that's a regression. In Django-1.7 with the following models:

{{{

from django.db import models


class Author(models.Model):
    name = models.TextField()


class Book(models.Model):
    author = models.ForeignKey(""Author"")
    title = models.TextField()
}}}

You can access `book.author` in the `ModelForm.save()` method:
admin.py:
{{{
from django import forms
from django.contrib import admin
from library import models


class BookForm(forms.ModelForm):
    class Meta:
        model = models.Book
        exclude = ()

    def save(self, *args, **kwargs):
        book = super(BookForm, self).save(*args, **kwargs)
        book.title = ""%s by %s"" % (book.title, book.author.name)
        return book


class BookInline(admin.TabularInline):
    model = models.Book
    extra = 1
    form = BookForm


class AuthorAdmin(admin.ModelAdmin):
    inlines = [BookInline]


admin.site.register(models.Author, AuthorAdmin)
}}}

And since commit [https://github.com/django/django/commit/45e049937d2564d11035827ca9a9221b86215e45 45e049937d] you get a `RelatedObjectDoesNotExist` exception: Book has no author.

Is it considered a normal behaviour?

Thanks.
"	Bug	closed	Documentation	1.8alpha1	Release blocker	fixed	inline ModelForm		Accepted	1	0	0	0	0	0
