Login

Snippets by code_shogan

Snippet List

restrict user access to modeladmin via metaclass

* Include `__metaclass__ = user_lock` to your ModelAdmin class * Add `__target__ = path_to_user_field` somewhere in the ModelAdmin * done! `__target__` is what will be used in the `filter` call. examples `'user'` or `'author'` or `'message__user'` e.t.c. The result of `__target__` is the field that is then checked against `request.user`

  • admin
  • user
  • restrict
  • model-admin
Read More

code_shogan has posted 1 snippet.