Django: agregar libros relacionados al autor

Lets take the standard example

class Author(models.Model):
  name = models.CharField(max_length=100)

class Book(models.Model):
  title = models.CharField(max_length=100)
  author = models.ForeignKey(Author)
  #... Many other fields ...

On the admin interface from the Author change page, I'd like to be able to add/edit his Books.

There you are going to tell me please RTFM and use a InlineModelAdmin.
But wait, as you can see there are "Many other fields" in Books and it will not be easily editable.

What I imagined is to be able to simply display the book titles in the Author change page, and supply links to add or edit his books. How can I do that ?

preguntado el 08 de noviembre de 11 a las 09:11

Hey. Think this should help you: stackoverflow.com/questions/5035709/… -

Thank you, it helped a lot, (and este también). If you want to make a little answer, I'll validate it with pleasure, even if it's just 1 or 2 links :) -

1 Respuestas

Puede anular el change_view and/or edit the change_form template.

There's a section in the docs you can consult on this topic: Overriding vs. replacing an admin template

Some more specific information can be found here: Mostrar enlace al formulario de cambio completo para el objeto en el administrador de django

contestado el 23 de mayo de 17 a las 15:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.