Answer the question
In order to leave comments, you need to log in
Why is relogin happening? (it is necessary to implement limited access if the logged in user does not match the one selected in the drop-down list)?
1. Based on the list of performers from the auth_user table, I build an html page
{% for us in users %}
{{ forloop.counter }}
<tr>
<th>{{ us.id }}</th>
<th><a href={% url 'projects' pk=us.id name=us.username %}> {{ us.username }}</a></th>
<th>{{ user.groups }}</th>
</tr>
{% endfor %}
url(r'^projects/(?P<name>\w+)-(?P<pk>\d+)/$', ProjectsView.as_view(), name='projects'),
class ProjectsView(DetailView):
model = User
template_name = 'projects.html'
def get_context_data(self, **kwargs):
context = super(ProjectsView, self).get_context_data(**kwargs)
modules = ModuleWork.objects.filter(executor=self.kwargs['pk'])
context['name'] = self.kwargs['name']
context['modules'] = modules
return context
{% block table %}
<div class="scrollable">
<table>
<thead>
<tr>
<th>#</th>
<th>Код проекта</th>
<th>Исполнитель проекта</th>
<th>Описание проекта</th>
<th>Дата проекта</th>
</tr>
</thead>
<tbody>
{% for module in modules %}
<tr>
<th>{{ module.pk }}</th>
<th><a href={% url 'module' pk=module.id%}>{{ module.project }}-{{ module.room }}{{ module.room_number }}-
{{ module.module }}{{ module.module_number }}</a></th>
<th>{{ module.executor }}</th>
<th>{{ module.project }}</th>
<th>{{ module.module_work_is_produced }}</th>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
Answer the question
In order to leave comments, you need to log in
javedimka @javedimka
Andrei Ramanchyk: One Google query said - apparently, DetailView returns two variables to the context through which you can access the object - object and the model name itself in lowercase, i.e. user, so your user is overwritten in the template.
Well, about request.user - in the new jungs it turns out that just user can be, as in your code, BUT since there is such a problem with names, direct access through request should solve the problem, and then - request.user.is_authenticated
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question