Tuesday, May 26, 2020

Read Text file in django

Good evening people,
i'm a beginner at django, i try to read a text file in django template but i only get the data.txt in template. how can i open and read the content of the text file in templates. Below you can see the html section and the output. Thanks in advance

Django model:
class Patienten(models.Model):
Name = models.CharField(max_length=50)
Vorname = models.CharField(max_length=50, null=True)
Geburtsdatum = models.DateField(max_length=10)
Strasse = models.CharField(max_length=100)
Ort = models.CharField(max_length=100, null=True)
Datum = models.DateField(max_length=10, null=True)
Versicherungsnummer = models.CharField(max_length=50)
Letzte_Diagnose = models.CharField(max_length=500)
Schrittinfos = models.FileField(max_length=100, null=True)


html part:
<a class="btn btn-default" href="{% url 'getAllPatienten' %}">Patientendaten<span class="glyphicon glyphicon-pencil"></span></a>
<h2>{% for post in posts%}</h2>
<h1>Patient:{{ post.Name }}</h1>
<p>Geburtsdatum:{{ post.Geburtsdatum|linebreaksbr }}</p>
<p>Versicherungsnummer:{{ post.Versicherungsnummer }}</p>
<p>Letzte Diagnose:{{ post.Letzte_Diagnose }}</p>
<p>Ort:{{ post.Ort }}</p>
<p>Datum:{{ post.Datum }}</p>
<p>Schrittinfos:{{ post.Schrittinfos }}</p>

html Output Part in Templates :

Patient:Sangare

Geburtsdatum:1990-05-30

Versicherungsnummer:D0469556541990

Letzte Diagnose:Gelenkschmerzen

Ort:Essen

Datum:May 26, 2020

Schrittinfos:data.txt


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/073bceca-3b93-4eb4-9647-873b7a7aa0fe%40googlegroups.com.

No comments:

Post a Comment