-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,25 @@ | ||
How to edit mutiple models from one Django admin? | ||
===================================================== | ||
|
||
To be able to edit multiple objects from one Django admin, you need to use inlines. | ||
|
||
You have the :code:`Category` model, and you need to add and edit :code:`Villain` models inside the admin for Category. You can do:: | ||
|
||
|
||
class VillainInline(admin.StackedInline): | ||
model = Villain | ||
|
||
@admin.register(Category) | ||
class CategoryAdmin(admin.ModelAdmin): | ||
.. | ||
|
||
inlines = [VillainInline] | ||
|
||
You can see the form to add and edit :code:`Villain` inside the :code:`Category` admin. If the Inline model has alot of fields, | ||
use :code:`StackedInline` else use :code:`TabularInline`. | ||
|
||
|
||
|
||
.. image:: edit_multiple_models.png | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters