Answer the question
In order to leave comments, you need to log in
How to give access to your objects?
I'm new to Django, don't scold me!
There is such an action
review_template = 'admin/netsch/item_view.html'
def item_view(self, request, id):
item = Netsch.objects.filter(pk=id)
works = Netschlistwork.objects.filter(netsch_id=id, type = 1).order_by("id")
works_admin = Netschlistwork.objects.filter(netsch_id=id, type = 2).order_by("id")
return render_to_response(self.review_template, {
'item':item,
'works':works,
'works_admin':works_admin,
'opts': self.model._meta,
}, context_instance=RequestContext(request))
Answer the question
In order to leave comments, you need to log in
Check if moderator or not and filter queryset if not:
qs = Item.objects.all()
if not user.is_moderator:
qs = qs.filter(user=user)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question