dudusf04 Posted January 14, 2020 at 09:49 AM Report Share #617053 Posted January 14, 2020 at 09:49 AM 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 comment Share on other sites More sharing options...
M6 Posted January 14, 2020 at 02:48 PM Report Share #617058 Posted January 14, 2020 at 02:48 PM 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 comment Share on other sites More sharing options...
dudusf04 Posted January 15, 2020 at 09:32 AM Author Report Share #617066 Posted January 15, 2020 at 09:32 AM (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 at 10:03 AM by dudusf04 Link to comment Share on other sites More sharing options...
M6 Posted January 15, 2020 at 11:53 AM Report Share #617069 Posted January 15, 2020 at 11:53 AM 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 comment Share on other sites More sharing options...
dudusf04 Posted January 15, 2020 at 02:02 PM Author Report Share #617071 Posted January 15, 2020 at 02:02 PM o device mostra um determinado dispositivo, neste código quero que mostra só os ficheiros de backup daquele dispositivo. Link to comment Share on other sites More sharing options...
M6 Posted January 15, 2020 at 02:41 PM Report Share #617073 Posted January 15, 2020 at 02:41 PM 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 comment Share on other sites More sharing options...
dudusf04 Posted January 15, 2020 at 05:08 PM Author Report Share #617076 Posted January 15, 2020 at 05:08 PM M6, entretendo já consegui o que eu queria. obrigado pela intenção. Link to comment Share on other sites More sharing options...
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