Wednesday, May 27, 2020

Re: Read Text file in django

Welcome 😊 anytime 😁

On May 27, 2020 23:30, "Lansana Sangare" <lansanas42@gmail.com> wrote:
Thanks guy, it works now

Ammar M. Adam <amarben1000@gmail.com> schrieb am Di., 26. Mai 2020, 23:43:

The FileField Must have a function for that
Use help(django.models.FileField)
It must have some sort of FileField.read() or something like that.
Am also a beginner but I think this should work with you 😉.

On May 26, 2020 23:34, "Lansana Sangare" <lansanas42@gmail.com> wrote:
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.

--
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/CAHs1H7utBp5rC9av1JM-qAgpRFe7mxiCx%3DS8KUWPJ05DGOHe%3Dw%40mail.gmail.com.

--
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/CAF4Pwrs4Ax8d9P-b%2B8PWdeNNU8R2KLh4x%3D94OQVWpn2MUALYLw%40mail.gmail.com.

--
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/CAHs1H7v_zV03DTA8Sd5LomUKnChBeG0yaj89uT%3DtXYsrBVJysQ%40mail.gmail.com.

No comments:

Post a Comment