Django name field: is it better to have the whole name in one field?
Is it better to have 3 fields in django model, "firs开发者_StackOverflow中文版t", "initial" and "last" or is it better to have "name" and put first name, last name and initial in the "name" field? If I put all three in one "name" field can I still search for last names?
I am asking because it will be easier to extract the "first, initial, last" from the scraped item.
Thanks
one day you will want to sort people by last name and will have to split merged names manually because with many people there will be numerous "formats"
I had to go through this once with ~300 records - lot's of fun copy-pasting. Sometimes you won't even know which name is first and which is last.
So you'll save yourself a lot of work in the future by keeping names separate.
If you want to query for (or sort by) last names, it's probably better to use three separate fields.
It's better to store the data in it's original form =D
(or close to the form you got it in as you can)
That being said... why not do both?
精彩评论