Admin page without inlines dinamically
Sometimes the related objects needs that the main object exists in order to edit and save them properly. There are two main solutions: override the ModelAdmin.add_view() view or remove the inlines only from the add view page (and not from the change page). The former requires a lot of coding, the latter it's impossible without patching Django because the inlines are not dynamic. **This simple solution hides the inline formsets only from the add page, and not from the change page.** Adding an "if" structure it is possible to choose the inlines to use. Example use case: when a related inline model have to save a file to a path that needs the ID key of the main model, this solution prevent the user to use the related inline model until the model it's saved. Tested on Django-1.4, should work since Django-1.2.
- admin
- inlines
- change_view
- add_view