I have a django site with lots of models and forms. I have many custom forms and formsets and inlineformsets and custom validation and custom querysets. Hence the add model action depends on forms that need other things, and the 'add model' in the django admin throughs a 500 from a custom queryset.
Is there anyway to disable the 'Add $MODEL' functionality for a certain models?
/admin/appname/modelname/add/ to give a 404 (or suitable 'go away' error message), I don't want the 'Add $MODELNAME' button to be on
Django admin provides a way to disable admin actions (http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#disabling-actions) however the only action for this model is 'delete_selected'. i.e. the admin actions only act on existing models. Is there some django-esque way to do this?
It is easy, just overload
has_add_permission method in your
Admin class like so:
class MyAdmin(admin.ModelAdmin): def has_add_permission(self, request, obj=None): return False
By default syncdb creates 3 security permissions for each model:
If your logged in as Admin, you get EVERYTHING no matter what.
But if you create a new user group called "General Access" (for example) then you can assign ONLY the CHANGE and DELETE permissions for all of your models.
Then any logged in user that is a member of that group will not have "Create" permission, nothing related to it will show on the screen.