Let's say I've created a (hopefully) reusable app, fooapp
:
urls.py
urls('^(?P<userid>\d+)/$', views.show_foo),
and fooapp's views.py:
def show_foo(request, userid):
usr = shortcuts.get_object_or_404(User, pk=userid)
... display a users' foo ...
return render_to_response(...)
Since it's a reusable app, it doesn't specify any access control (e.g. @login_required
).
In the site/project urls.py, the app is included:
urls('^foo/', include('fooapp.urls')),
How/where can I specify that in this site only staff members should be granted access to see a user's foo?
How about if, in addition to staff members, users should be able to view their own foo (login_required
+ request.user.id == userid
)?
I didn't find any obvious parameters to include..
Note: this has to do with access control, not permissions, i.e. require_staff
checks User.is_staff
, login_required
checks if request.user
is logged in, and user-viewing-their-own-page is described above. This question is in regards to how a site can specify access control for a reusable app.