Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for get_formset on inline admin #128

Merged
merged 1 commit into from
Jun 15, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,13 @@ You may use AjaxSelectAdmin as a mixin class and multiple inherit if you have an
autoselect_fields_check_can_add(form, self.model, request.user)
return form

If you are using ajax select fields on an Inline form in Django Admin, you should override get_formset to check permission and include the add button when appropriate:

def get_formset(self, request, obj=None, **kwargs):
formset = super(YourAdminClass, self).get_form(request, obj, **kwargs)
autoselect_fields_check_can_add(formset.form, self.model, request.user)
return formset

Note that ajax_selects does not need to be in an admin. Popups will still use an admin view (the registered admin for the model being added), even if the form from where the popup was launched does not.


Expand Down