Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

509
Visualizações
Django how to open and display saved docx or pdf documents

I'm currently working on a question bank website using Django 1.87 that allow users o login and view saved past questions. so far i have been able to display links to the past questions in the database base on user selection. the past questions are uploaded as docs or PDF format and stored in the media directory.

I want logged in users to be able to open and read the content of the past question before deciding whether to print or download it. so far i have been able to display a list of links to the documents and when i click on a link it downloads the document to my computer. what i really want to achieve is for users to be able to click on a link and open the document from within the browser before clicking a download buttenter code hereon or print.

here are my codes:

models.py

class QuestionBank(models.Model):

date = models.DateField(_("Date"),default=date.today)
class_level = models.ForeignKey(ClassLevel)
course_name = models.CharField(max_length=350)
course_code = models.CharField(max_length=20)
question_papers = models.FileField(upload_to = 'Question_Papers/     %y/%m/%d')   

views.py def Questions(request, sel_course):

context = RequestContext(request)
SelCourse = sel_course.replace('_',' ')
context_dict = {'SelCourse':SelCourse}

try:
    Quest_For_course = QuestionBank.objects.filter(course_code = SelCourse)
    context_dict['Quest_For_course'] = Quest_For_course

except course_code.DoesNotExist:
    pass

return render_to_response('Qbank/QuestionsPage.html', context_dict, context)

in my Template i have this

QuestionsPage.html

<title> Question Papers </title> 

<body> 
    <h2> LIST OF QUESTION PAPERS FOR {{selCourse}} </h2>

    <h3> Select question to view, download or print it</h3>

    {% if Quest_For_course %}

    <ul>{% for ques in Quest_For_course %}

    <li><a href="{{ques.question_papers.url}}"> 

    {{ques.question_papers}} </a></li>

    {%endfor%}
    </ul>

    {%else%}
    <strong> THERE ARE NO AVAILABLE QUESTION FOR THIS CLASS AT THE MOMENT </strong>
    {%endif%}
</body>

how do i make past question documents view-able? on a form that has download and print button. thanks

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda