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

123
Visualizações
how to copy variable to [clipboard] in django template

How do I copy a variable from inside the html page of Django templates?

render(request, 'doc.html', {'stack': stack, 'text':text,})
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your question may not seem clear enough to describe what you want or describe your problem, but some of my guesses for the solution are that you need to use js code in your template, specifically document.text.select() and document.execCommand('copy').

Perhaps the following example will suffice:

in html code

<html>
<body>
     <button style="background:green; text-align:center;" onclick="CopyText()">Copy Text</button>
     <input style="text-align:center;" type="text" value="{{text}}"id="yourtext">
</body>
</html>

javascript:

{% block scripts %}
<script>
  function CopyText() {
  var text = document.getElementById('yourtext')
  text.select();
  document.execCommand('copy')
}
</script>
{% endblock scripts %}

In the example shown above, we used the value of the variable that you send to the template as a default value in the text tag, and then we specify the text through the tag's ID yourtext, and then execute the copy command. It may not seem perfect but it is enough to solve your problem.

about 4 years ago · Juan Pablo Isaza Relatório
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