Skip to content

Conversation

@PouyaMohseni
Copy link
Contributor

@PouyaMohseni PouyaMohseni commented Dec 10, 2025

Source input in AddName form:
Ex

Instrument detail for long sources:
ex
ex

ref #455

@dchiller
Copy link
Contributor

I agreed with you in the issue that this would be a display problem... why not save the entire source name though and truncate it for display, perhaps using a truncate template tag

@PouyaMohseni
Copy link
Contributor Author

Thank you, I will do that instead. But don't we need some kind of a max_length for are free-text entries?

@dchiller
Copy link
Contributor

Thank you, I will do that instead. But don't we need some kind of a max_length for are free-text entries?

Do you mean in terms of a database constraint? You could use a text field... or put a max character that's really generous?

@ahankinson
Copy link
Member

The max length of a CharField is 255 characters.

Do you mean in terms of a database constraint? You could use a text field... or put a max character that's really generous?

In general you should choose a length that will serve the purpose, but not so long that people are tempted to write their life's story in the field. "The piano my grandmother gave me when I was ten and which I have many fond memories of" is not a suitable title, so if you truncate it to something reasonable then that removes this temptation.

Django should raise a ValidationError if a user tries to save the field over the max length, so there is no risk of silently corrupting the user input. Personally, I would suggest shorter is better than longer since you want to encourage succinctness in naming.

@dchiller
Copy link
Contributor

I wonder what the max length of names currently in DB is? Seems like a good gut check of where that field might max out.

In either case, this limit should be transparent to user who should then be forced to truncate.

Although source isn't particularly well-defined, I'd argue if we can't fit a standard-ish academic citation we need to rethink. Perhaps such a citation isn't a source "name", and this is a limitation of the current basic Source model. In any case, I'd be fine, for the present, with modifying this to force the user to provide a valid-length string, rather than truncating.

@PouyaMohseni
Copy link
Contributor Author

We have some very long instrument names that appear to be the result of incorrect alias input in Wikidata.

Bayan, 84 characters in Spanish
Turi, 85 characters in English

Example

@dchiller
Copy link
Contributor

We have some very long instrument names that appear to be the result of incorrect alias input in Wikidata.

Ah, yes; I agree, that looks like someone didn't enter them as separate labels...

I just fixed both of those on Wikidata.

- reduce the size of the language input to have everything shown in one row
- reword source overflow error
@PouyaMohseni PouyaMohseni changed the title fix: if name and source entry is longer than max_lenght, slice it to prevent overflow fix: prevent source and language name overflow Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants