Answer the question
In order to leave comments, you need to log in
Why when the id becomes two-digit when filling the rows of the table, I get the error keyword arguments '{'pk': 12}' not found?
The following error takes off from the moment when the 10th record appears in the table. The table looks something like this
I'm going from my html page 'executor.html'
<tbody>
{% for us in users %}
<tr>
<th>{{ us.id }}</th>
<th>
{% ifequal us request.user %}
<a href={% url 'projects' pk=us.id name=us.username %}> {{ us.username }}</a>
{% else %} {{ us.username }}
{% endifequal %}
</th>
<th>{{ us.email }}</th>
</tr>
{% endfor %}
</tbody>
class ExecutorView(TemplateView):
template_name = 'executor.html'
context_object_name = 'executors'
def get_context_data(self, **kwargs):
context = super(ExecutorView, self).get_context_data(**kwargs)
users = User.objects.all()
context['users'] = users
return context
class ProjectsView(DetailView):
# model = User
model = ModuleWork
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']).order_by('-module_work_data')
context['name'] = self.kwargs['name']
context['modules'] = modules
return context
{% block table %}
<div class="scrollable">
<table>
<thead>
<tr>
<th>#</th>
<th>Code project</th>
<th>Type module</th>
<th>Data</th>
<th>Engineer</th>
<th>Description</th>
<th>Is produced?</th>
</tr>
</thead>
<tbody>
{% for module in modules %}
<tr>
<th>{{ module.pk }}</th>
<th><a href={% url 'project_module' pk=module.id %}>{{ module.project }}-{{ module.room }}{{ module.room_number }}-
{{ module.module.module_symbol }}{{ module.module_number }}</a></th>
<th>{{ module.module.module_name }}</th>
<th>{{ module.module_work_data }}</th>
<th>{{ module.executor }}</th>
<th>{{ module.project }}</th>
<th>{{ module.module_work_is_produced }}</th>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
urlpatterns = [
url(r'^tutorial/', include('django_tutorial.urls')),
url(r'^projects/photo$', ProjectsPhotoView.as_view(), name='projects_photo'),
url(r'^login/$', LoginView.as_view(), name='authenticate'),
url(r'^logout/', LogoutView.as_view(), name="log_aut"),
url(r'^project_create/$', NewProjectCreate.as_view(), name='new_project'),
url(r'^create/module/$', permission_required('Module.can_add_new_module')(ModuleCreateView.as_view()),
name='new_module'),
url(r'^projectobjectives/create/(?P<pk>\d+)$', TaskItemCreate.as_view(), name='create'),
url(r'^projectobjectives/delete/(?P<pk>\d+)-(?P<id>\d+)$', TaskItemDelete.as_view(), name='delete'),
url(r'^projectobjectives/edit/(?P<pk>\d+)-(?P<id>\d+)$', TaskItemEdit.as_view(), name='edit'),
url(r'^test/$', TemplateView.as_view(template_name='index.html'), name='index'),
url(r'^module/project_objectives/(?P<pk>\w)/$', ProjectObjectivesView.as_view(), name='project_objectives'),
url(r'^projects/module/(?P<pk>\d)/photo$', ModulePhotoView.as_view(), name='project_module_photo'),
url(r'^projects/module/(?P<pk>\d)/$', ModuleView.as_view(), name='project_module'),
url(r'^basic/module/(?P<pk_old>\w)/(?P<pk>\w)/$', BasicModuleDetailsView.as_view(), name='basic_module_detail'),
url(r'^basic/module/(?P<pk>\w)/$', BasicModuleView.as_view(), name='basic_module'),
url(r'^admin/', admin.site.urls),
url(r'^rooms/(?P<pk>\w+)/$', RoomView.as_view(), name='rooms'),
url(r'^create/important-features/$', ImportantFeaturesCreate.as_view(), name='important_features_create'),
url(r'^projects/(?P<name>\w+)-(?P<pk>\d+)/$', ProjectsView.as_view(), name='projects'),
url(r'^projects/all/$', login_required(ProjectsAllView.as_view()), name='projects_all'),
url(r'^executor/$', ExecutorView.as_view(), name='executor'),
url(r'^$', HomeView.as_view(), name='home'),
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question