Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6323345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:29:59+00:00 2026-05-24T16:29:59+00:00

In summary: I have a mysql db table that holds pdf objects. When a

  • 0

In summary: I have a mysql db table that holds pdf objects. When a user prints one of them, I want the table to update with the time, date, printed boolean value, and the user that printed the pdf object. This user information should write the value for the user currently logged in. I have all of these currently updating when a pdf is printed with the exception of user. I have tried using request.user but that does not seem to work within a queryset or else I am missing something. I have also tried using methodology similar to how I have defined get_user, which allows me to manually set the user, but again, that is not within the queryset to update automatically. Any help is much appreciated! My admin.py file is as follows:

from django.contrib import admin
from django.contrib.auth.models import User
from djangostuff.pdf.models import ABC
from django.http import HttpResponse
import datetime, time

class ABCAdmin(admin.ModelAdmin):

    actions = ['print_selected_pdf']

    def get_user(self):
        return '%s'%(self.user.username)

    def create_pdf(self, queryset):
        response = HttpResponse(mimetype="application/pdf")
        response['Content-Disposition'] = 'attachment; filename=form.pdf'
        for obj in queryset:
            response.write(obj.form)
            ABC.objects.filter(pk=obj.pk).update(pdf_printed="1",request_time=time.strftime("%H:%M:%S"),request_date=datetime.datetime.today())
            ABC.objects.filter(pk=obj.pk).update(user=request.user)

        return response


    def print_selected_pdf(self, request, queryset):
        # prints the pdfs for those that are selected,
        # regardless if the pdf_printed field is true or false
        qs = queryset.filter(pdf_printed__exact=0)
        return self.create_pdf(qs)

    print_selected_pdf.short_description = "Print Selected PDF"

    get_user.short_description='Printed By'

    list_display=('form_no',get_user,'request_date','request_time','pdf_printed')


admin.site.register(ABC, ABCAdmin)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:30:00+00:00Added an answer on May 24, 2026 at 4:30 pm

    Why not just pass request as an argument to create_pdf?

    def create_pdf(self, request, queryset):
        ...
    
    def print_selected_pdf(self, request, queryset):
        qs = queryset.filter(pdf_printed__exact=0)
        return self.create_pdf(request, qs)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a report that pulls information from a summary table and ideally will
So I have several summary files that I want to read and get the
Suppose I have a MySQL table of one column: Message. It is of type
You may have noticed that we now show an edit summary on Community Wiki
Let's say that I have a widget that displays summary information about how many
I have an application, built using MVC, that produces a view which delivers summary
I have two entities, a User and Role with a one-to-many relationship from user
I have three tables in MySQL that are related, yet not technically linked to
I have a user system set up in a 'users' table, and I have
Summary: I have a struct that is read/written to file. This struct changes frequently,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.