I have a webapp where a user can upload a pdf. I want to be able to see how many times the PDF is viewed by other user, all of which would be anonymous users. At the moment I didn't have to write a view to view the PDF, in the 'view PDF' button i Just link the uploaded PDF's URL, which directs to the PDF document.
Button to view PDF
<a href="{{ doc.File.url }}" class="btn btn-outline-secondary" style="margin: 2px;">View PDF</a>
The issue arises, in that when a user uploads a PDF doc, i create a qr code which contains the URL of that doc. So i only want to count the views that are from the qr scan in, and not redirected from the button. How can i do this seeing as i don't actually have a view to render the PDF?
One way i was thinking of is writing a return redirect view, with an incrementer for the views instance in the model? or to use the Django F() statement to pull in the views instance and then increment it.
Any ideas?
For the QR code, you could encode the URL as
URL + "&qr=true"
. That way it will show up in your HTTP logs with a different URL.