Django field additional question.

Asked 2 years ago, Updated 2 years ago, 40 views

Question about adding Django model field ^

^
class ActressInfo(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=100)
    birth = models.CharField(max_length=100)
    starsign = models.CharField(max_length=50)
    bloodtype = models.CharField(max_length=50)

Among the models above, the data in the name field is Chinese. I want to convert this data into English and Korean and store it in the data, but I want to add a new English and Korean name field to the same model class, or I want to modify and save it in the same way as Chinese/English/Korean.

Originally, I was going to create a child class, but I'm looking for a way to add it to the same class because I think it'll be easier to manage.

Maybe it's a beginner, but I don't know what to do.

I wonder how I usually code the things I want.

Please give us a hint !

!!

django python

2022-09-21 21:00

1 Answers

If you don't need to search by name or sort at all, you can save it as Chinese/English/Korean in one field, but if you need to search or sort, you need to divide the fields.

If the numbers in the language are fixed, it would be better to add three fields to one model.

If the number of languages is flexible (if Japanese, Mongolian, or Vietnamese may be added soon), it would be better to create a separate model (table). In this case, a separate model should have the following fields:


2022-09-21 21:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.