I have a Print button in the Django Admin table that passes information to the template. I want to add a link to the Action dropdown that will duplicate the Print button, after having checked the required fields, I could select Print in Action dropdown and display the information in the templates.

But when I added a link to Action dropdown, I started to get an error. Help add Action dropdown.

admin.py

@admin.register(Salary) class SalaryAdmin (admin.ModelAdmin): list_display = ('worker', 'salary_uah', 'dates', 'button') search_fields = ('worker', 'salary_uah', 'dates') list_filter = ('worker', 'date') actions = ['button'] def button(self, request, queryset): a= queryset.values() return '<a class="button" href="{}">Print</a>'.format(reverse('act',args=a)) button.short_description = 'Actions' button.allow_tags = True 

urls.py

 urlpatterns = [ url(r'^$',home, name='home'), url(r'^add/$',add_worker, name='add'), url(r'^act/(?P<obj>[\w-]+)$',acts, name='act') ] 

models.py

 class Salary (models.Model): worker = models.ForeignKey(Worker) salary_uah = models.IntegerField ('Salary') date = models.DateTimeField('Date', default=datetime.datetime.utcnow()) 

views.py

 def acts (request, obj): if not request.user.is_authenticated(): return redirect('admin:login') salary = Salary.objects.get(id=obj) workers = Worker.objects.filter(id=salary.worker.pk).values() salary = Salary.objects.filter(id=obj).values() return render(request, 'zpapp/act.html', {'workers':workers, 'salary':salary }) 

error message:

  `NoReverseMatch at /admin/zpapp/salary/ Reverse for 'act' with arguments '({'date': datetime.datetime(2017, 1, 11, 10, 11, 55, tzinfo=<UTC>), 'id': 1, 'salary_uah': 232323, 'worker_id': 1},)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['act/(?P<obj>[\\w-]+)$']` 

How can I get the id value from Quereset?

I tried a.get('id') , but again I stumbled upon an error:

FieldError at /admin/zpapp/salary/ Cannot resolve keyword 'i' into field. Choices are: date, id, salary_uah, worker, worker_id

    0