can we save list in mysql with django model
Yes, we can save a list in MySQL with Django model. We can use the "ArrayField" of Django's PostgreSQL extension to store a list of values in a single field in MySQL. However, MySQL does not have a built-in array data type, so we need to use a third-party library like django_mysql to use ArrayField in MySQL.
Here is an example of using ArrayField to store a list of integers in a Django model:
from django.db import models
from django_mysql.models import ListIntegerField
class MyModel(models.Model):
    name = models.CharField(max_length=50)
    numbers = ListIntegerField()
In the above example, we have used ListIntegerField to store a list of integers in the "numbers" field of the MyModel model. We can use this field to store and retrieve a list of integers from MySQL using Django ORM.
原文地址: https://www.cveoy.top/t/topic/1pi 著作权归作者所有。请勿转载和采集!