tango ward
tango ward

Reputation: 327

Textfield Length Django

I am trying to get a len of a textfield in Django so I can manipulate it in my template since the name of the school is too long, it is overlapping in the PDF display. I found this old post here in SO How to get the length of a TextField in Django?

I am trying to get the length of a school field which is related to another model.

x = Recipient.objects.get(id='1234551')
len(x.department.school)

This gives me an error: object of type 'Recipient' has no len(). School is also a field and it seems to work on the old post. I just don't understand why it doesn't work in my end.

Upvotes: 1

Views: 242

Answers (1)

Ralf
Ralf

Reputation: 16495

What kind of field is x.department.school ? Is that the CharField or the ForeignKey?

Or maybe it has to be something like len(x.department.school.name) ?

You will have to post your models for us to give a complete answer.

Upvotes: 1

Related Questions