dudusf04 0 Posted January 14, 2020 Report Share Posted January 14, 2020 Olá, Alguém poderá explicar a funcionalidade include em um html e djnago e como posso obter dados staticos deste html? Desde já muito obrigado pelo apoio. Link to post Share on other sites
M6 153 Posted January 14, 2020 Report Share Posted January 14, 2020 Já fizeste o tutorial? Explica tudo direitinho. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to post Share on other sites
dudusf04 0 Posted January 15, 2020 Author Report Share Posted January 15, 2020 (edited) Olá M6, Desde já obrigado pela explicação. Já estive a estudar na documentação e também vendo uns vídeos no youtube. A questão é a seguinte, eu criei um dicionário na views.py que faz uma listagem de ficheiros criei a rota para file_backup.html, até ai tudo bem, quando no device faço o include só aparece o que está em HTML, o que está em python não. views.py def File_b(request): path = '/opt/netbox/netbox/static/backup' allfiles = [] # r=root, d=directories, f = files for r, d, f in os.walk(path): for fil in f: if '.txt' in fil: allfiles.append(os.path.join('backup/', fil)) if '.xml' in fil: allfiles.append(os.path.join('backup/', fil)) return render(request, 'dcim/file_backup.html', { 'files':allfiles,}) urls.py # file backups path(r'file_backup/', views.File_b, name='files'), file_backup.html {% load static %} <table class="table table-hover panel-body"> <tr> <th>Name</th> <th>Size</th> <th>Created</th> <th></th> </tr> {% for fil in files %} <tr{% if not file.size %} class="danger"{% endif %}> <td> <i class="fa fa-image"></i> <a href="{% static fil %}" target="_blank">{{ fil }}</a> </td> <td>{{ fil.size|filesizeformat }}</td> <td>{{ fil.created }}</td> </tr> {% endfor %} </table> device.html <div class="panel panel-default"> <div class="panel-heading"> <strong>Backup</strong> </div> {% include 'dcim/file_backup.html' %} {% if perms.extras.add_imageattachment %} <div class="panel-footer text-right noprint"> <a href="https://ipam.winprovit.pt/dcim/file_backup/" target="_blank" class="btn btn-xs btn-primary"> <span class="glyphicon" aria-hidden="true"></span> backups </a> </div> {% endif %} </div> Edited January 15, 2020 by dudusf04 Link to post Share on other sites
M6 153 Posted January 15, 2020 Report Share Posted January 15, 2020 O que é "correr no device"? 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to post Share on other sites
dudusf04 0 Posted January 15, 2020 Author Report Share Posted January 15, 2020 o device mostra um determinado dispositivo, neste código quero que mostra só os ficheiros de backup daquele dispositivo. Link to post Share on other sites
M6 153 Posted January 15, 2020 Report Share Posted January 15, 2020 Não estou a conseguir compreender o teu problema. Tens um bug no código? Não consegues passar a informação do controlador para a view? Tens outro problema? 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to post Share on other sites
dudusf04 0 Posted January 15, 2020 Author Report Share Posted January 15, 2020 M6, entretendo já consegui o que eu queria. obrigado pela intenção. Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now