Answer the question
In order to leave comments, you need to log in
How to display data from a table decoded via base64?
In a Postgres table, one of the fields stores data in base64. They need to be output by running through decode(), and the rest - as is.
models.py:
class Local(models.Model):
packet = models.TextField(blank=True) #он в base64
protocol = models.TextField(blank=True)
srcaddr = models.TextField(blank=True)
srcport = models.TextField(blank=True)
dstaddr = models.TextField(blank=True)
dstport = models.TextField(blank=True)
ttl = models.TextField(blank=True)
capturetime = models.TextField(blank=True)
def local(request):
table = Local.objects.order_by('-id')
return render(request, "local.html",{"packets": table}) #сейчас передача всего как есть
<tbody>
{% for p in packets %}
<tr>
<td>
<details>
<summary>{{ p.capturetimel}}{{ p.protocol}}{{ p.srcaddr}}{{ p.srcport}} {{ p.dstaddr}} {{ p.dstport}} {{ p.ttl}}</summary>
<pre>
{{ p.packet }}
</pre>
</td>
</tr>
{% endfor %}
</tbody>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question