You should inline Books, not Author. So: class BookInline(admin.TabularInline): model = Book
class AuthorAdmin(admin.ModelAdmin): ... inlines = [BookInline, ] and then you'll be able to create books in the same time as creating authors. (Books form already has author (foreign key) field without any additional action). On Jan 30, 5:49 am, Rishabh Manocha <rmano...@gmail.com> wrote: > Hey guys, > I've been trying to get InlineModelAdmin objects setup in my admin > app, but am unable to figure out how to do so correctly. Using the > same example as the one listed in the docs [1]: > > class Author(models.Model): > name = models.CharField(max_length=100) > > class Book(models.Model): > author = models.ForeignKey(Author) > title = models.CharField(max_length=100) > > What I would like to do is have the Author creation form show up in > with the Book creation form - so basically, my admin.py code would > look something like: > > class AuthorInline(admin.TabularInline): > model = Author > > class BookAdmin(admin.ModelAdmin): > ... > inlines = [AuthorInline, ] > > However, when I try this, I get an error: > > Exception Value: <class 'testapp.models.Author'> has no ForeignKey to > <class 'testapp.models.Book'>. > > So, I was wondering if anyone knows how I could get an Author creation > form show up inline with on the 'Add Book' page. > > Thanks. > > -- > > Best, > > R > > [1] - http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodelad... -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.