Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've defined a model class in MyApp/models.py:

Python
class Machine_Category(models.Model):
    category = models.CharField(max_length = 100)
    
    def __str__(self):
        return self.category

class Machine(models.Model):
    machine_id = models.CharField(max_length = 100)
    
    category = models.ForeignKey(Machine_Category, on_delete = models.CASCADE)


in http://127.0.0.1:8000/admin/cm/machine_category/ when I want to add a new Machine_Category which category = "线路曝光机", (some Chinese characters). There are some errors occur:
'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

so when I change category = "exposure" which are not Chinese characters. it can be added successfully.

HOW CAN I ADD CHINESE CHARACTERS?

What I have tried:

when I change category = "exposure" which are not Chinese characters. it can be added successfully.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900