You can convert it into string by using JSON and store it as string.

For example,

In [3]: json.dumps([[1, 3, 4], [4, 2, 6], [8, 12, 3], [3, 3, 9]])

Out[3]: '[[1, 3, 4], [4, 2, 6], [8, 12, 3], [3, 3, 9]]'

You can add a method into your class to convert it automatically for you.

import json


class Foobar(models.Model):
    foo = models.CharField(max_length=200)

    def set_foo(self, x):
        self.foo = json.dumps(x)

    def get_foo(self):
        return json.loads(self.foo)

If you're using Django 1.9 or above, and you use postgresql, there is a new class called JSONField, you should use it instead. Here is a link to it

There is a good talk about PostgreSQL JSONs and Arrays on youtube. Watch it, it has very good information.

Answer from Ahmed on Stack Overflow
🌐
Readthedocs
django-mysql.readthedocs.io › en › latest › model_fields › list_fields.html
List Fields - django-mysql 4.19.0 documentation
>>> from django_mysql.models import ListF >>> Person.objects.filter(post_nominals__contains="PhD").update( ... post_nominals=ListF("post_nominals").append("Sr.") ... ) 2 >>> Person.objects.update(post_nominals=ListF("post_nominals").pop()) 3 ... >>> horatio = Person.objects.get(name="Horatio") >>> horatio.post_nominals = ListF("post_nominals").append("DSocSci") >>> horatio.save() ... You should instantiate this class with the name of the field to use, and then call one of its methods.
🌐
GeeksforGeeks
geeksforgeeks.org › python › django-model-data-types-and-fields-list
Django Model Data Types and Fields List - GeeksforGeeks
Reserved names like save, delete, and clean should not be used as field names to avoid conflicts with Django’s model system. ... from django.db import models class Musician(models.Model): first_name = models.CharField(max_length=200) last_name = models.CharField(max_length=200) instrument = models.CharField(max_length=200) class Album(models.Model): artist = models.ForeignKey(Musician, on_delete=models.CASCADE) name = models.CharField(max_length=100) release_date = models.DateField() num_stars = models.IntegerField()
Published   November 14, 2025
Discussions

python - Storing list of objects in Django model - Stack Overflow
Is there a way in Django to have multiple objects stored and manageable (in Django admin) inside another object? Example, I have two models: Items and RMA. The RMA may have multiple Items insid... More on stackoverflow.com
🌐 stackoverflow.com
How to get a list of the fields in a Django model? - Stack Overflow
I've defined a User class which (ultimately) inherits from models.Model. I want to get a list of all the fields defined for this model. For example, phone_number = CharField(max_length=20). Basical... More on stackoverflow.com
🌐 stackoverflow.com
How to get all fields for a Django model? - Stack Overflow
This method is used to introspect the model's fields, their types, and their relationships with other models. The method returns a list of Field objects, which represent the individual fields in the model. For example, suppose you have a Django model called MyModel. More on stackoverflow.com
🌐 stackoverflow.com
Getting the correct list of objects
If I can have one more question (these are my first days with Python and Django) I have three models: class Guardian(models.Model): guardian_first_name = models.CharField(max_length=50, verbose_name='Imię opiekuna') guardian_last_name = models.CharField(max_length=100, verbose_name='Nazwisko ... More on forum.djangoproject.com
🌐 forum.djangoproject.com
1
0
January 20, 2022
Top answer
1 of 9
143

You can convert it into string by using JSON and store it as string.

For example,

In [3]: json.dumps([[1, 3, 4], [4, 2, 6], [8, 12, 3], [3, 3, 9]])

Out[3]: '[[1, 3, 4], [4, 2, 6], [8, 12, 3], [3, 3, 9]]'

You can add a method into your class to convert it automatically for you.

import json


class Foobar(models.Model):
    foo = models.CharField(max_length=200)

    def set_foo(self, x):
        self.foo = json.dumps(x)

    def get_foo(self):
        return json.loads(self.foo)

If you're using Django 1.9 or above, and you use postgresql, there is a new class called JSONField, you should use it instead. Here is a link to it

There is a good talk about PostgreSQL JSONs and Arrays on youtube. Watch it, it has very good information.

2 of 9
57

If you're on Django 1.10 or newer AND Postgres as your database, you can use ArrayField. It's better to use than django-taggit or other alternatives, as it's native to the Django framework. https://docs.djangoproject.com/en/3.1/ref/contrib/postgres/fields/#arrayfield

from django.db import models
from django.contrib.postgres.fields import ArrayField

class ChessBoard(models.Model):
    board = ArrayField(
        ArrayField(
            models.CharField(max_length=10, blank=True),
            size=8,
        ),
        size=8,
    )

If you're on Django 3.1 or newer they've added support for JSONField with most database backends (MariaDB 10.2.7+, MySQL 5.7.8+, Oracle, PostgreSQL, and SQLite 3.9.0+). You can use this to store your Array!

https://docs.djangoproject.com/en/3.1/ref/models/fields/#jsonfield

from django.db import models

class ChessBoard(models.Model):
    list_of_pieces = models.JSONField()
Top answer
1 of 16
391

Django versions 1.8 and later:

You should use get_fields():

[f.name for f in MyModel._meta.get_fields()]

The get_all_field_names() method is deprecated starting from Django 1.8 and will be removed in 1.10.

The documentation page linked above provides a fully backwards-compatible implementation of get_all_field_names(), but for most purposes the previous example should work just fine.


Django versions before 1.8:

model._meta.get_all_field_names()

That should do the trick.

That requires an actual model instance. If all you have is a subclass of django.db.models.Model, then you should call myproject.myapp.models.MyModel._meta.get_all_field_names()

2 of 16
124

As most of answers are outdated I'll try to update you on Django 2.2 Here posts- your app (posts, blog, shop, etc.)

1) From model link: https://docs.djangoproject.com/en/stable/ref/models/meta/

from posts.model import BlogPost

all_fields = BlogPost._meta.fields
#or
all_fields = BlogPost._meta.get_fields()

Note that:

all_fields=BlogPost._meta.get_fields()

Will also get some relationships, which, for ex: you can not display in a view.
As in my case:

Organisation._meta.fields
(<django.db.models.fields.AutoField: id>, <django.db.models.fields.DateField: created>...

and

Organisation._meta.get_fields()
(<ManyToOneRel: crm.activity>, <django.db.models.fields.AutoField: id>, <django.db.models.fields.DateField: created>...

2) From instance

from posts.model import BlogPost

bp = BlogPost()
all_fields = bp._meta.fields

3) From parent model

Let's suppose that we have Post as the parent model and you want to see all the fields in a list, and have the parent fields to be read-only in Edit mode.

from django.contrib import admin
from posts.model import BlogPost 

@admin.register(BlogPost)
class BlogPost(admin.ModelAdmin):
    all_fields = [f.name for f in Organisation._meta.fields]
    parent_fields = BlogPost.get_deferred_fields(BlogPost)

    list_display = all_fields
    read_only = parent_fields
🌐
Django Documentation
docs.djangoproject.com › en › 5.0 › topics › db › models
Models | Django documentation | Django
Fields are specified by class attributes. Be careful not to choose field names that conflict with the models API like clean, save, or delete. ... from django.db import models class Musician(models.Model): first_name = models.CharField(max_length=50) ...
Find elsewhere
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn › Server-side › Django › Models
Django Tutorial Part 3: Using models - Learn web development | MDN
October 24, 2024 - In the discussion below, we'll refer to a Book model with title and genre fields, where genre is also a model with a single field name. We can get all records for a model as a QuerySet, using objects.all(). The QuerySet is an iterable object, meaning that it contains a number of objects that we can iterate/loop through. ... Django's filter() method allows us to filter the returned QuerySet to match a specified text or numeric field against particular criteria.
🌐
GitHub
gist.github.com › 1200165
Howto use ListFields in Django's admin · GitHub
This will covert the comma-separated input box contents into a Python list, and the list value that is fetched from the database int a comma-separated string which is then displayed in the input box. Let's add a post and check out the resulting model object in the database:
🌐
Yuji Tomita
yujitomita.com › 2008 › 05 › 14 › django-list-all-fields-in-an-object
Django — List all fields in an Object - Yuji Tomita
June 30, 2011 - This it’s good but, if we have a ManyToManyField on model then _meta.fields() doesn’t get it. ... Thanks….that _meta._many_to_many() worked … !!! ... Try mode_instance._meta.get_all_field_names(). You’ll need to filter out ‘id’, but it includes many-to-many fields and saves you the step of having to look up the name out of the field object. ... You can also use django.forms.models.model_to_dict and call .keys() on the result.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-get-a-list-of-the-fields-in-a-django-model
How to Get a List of the Fields in a Django Model - GeeksforGeeks
July 23, 2025 - Each Django Model has a protected _meta attribute which we can use to get all fields and individual fields. ... In this guide, we’ll explore how to access the list of fields from a Django model and use it in your project.
🌐
Django Documentation
docs.djangoproject.com › en › 5.0 › ref › models › fields
Model field reference | Django documentation | Django
Note that choices can be any sequence object – not necessarily a list or tuple. This lets you construct choices dynamically. But if you find yourself hacking choices to be dynamic, you’re probably better off using a proper database table with a ForeignKey. choices is meant for static data that doesn’t change much, if ever. ... A new migration is created each time the order of choices changes. For each model field that has choices set, Django will normalize the choices to a list of 2-tuples and add a method to retrieve the human-readable name for the field’s current value.
🌐
Django Forum
forum.djangoproject.com › using django
Getting the correct list of objects - Using Django - Django Forum
January 20, 2022 - If I can have one more question (these are my first days with Python and Django) I have three models: class Guardian(models.Model): guardian_first_name = models.CharField(max_length=50, verbose_name='Imię opiekuna') guardian_last_name = models.CharField(max_length=100, verbose_name='Nazwisko opiekuna') guardian_login = models.CharField(max_length=50, verbose_name='Login') class Baby(models.Model): class Meta: verbose_name_plural = 'Babies' first_name = models.CharF...
🌐
Sezer BOZKIR
sezerbozkir.com › main page › how to store list type field in django? (3 different solutions)
How To Store List Type Field In Django? (3 Different Solutions) - Sezer BOZKIR
October 17, 2022 - Let’s say you have a web project and one of your fields in the database needs to be listed. However, you need an alternative solution as you cannot keep the list directly in the database by default. How can you solve it? If the database you are using supports the JSON data type, this solution is easy to implement. Let’s say you are building a database of a car trading company and you decide to keep a list of models under each brand; from django.db import models import json class Brand(models.Model): brand_name = models.CharField(max_length=200) _car_models = models.CharField(db_column="car_models", max_length=500) @property def car_models(self): return json.loads(self._car_models) @car_models.setter def car_models(self, x): self._car_models = json.dumps(x)
🌐
Django
django.how › models › data-types-and-fields-list
Data Types and Fields List Django.How
DurationField A field for storing periods of time. EmailField It is a CharField that checks that the value is a valid email address. FileField It is a file-upload field. FloatField It is a floating-point number represented in Python by a float instance. ImageField It inherits all attributes and methods from FileField, but also validates that the uploaded object is a valid image.
🌐
W3Schools
w3schools.com › django › django_admin_set_list_display.php
Django Admin - Set Fields to Display
from django.db import models class ... object tutorial. We can control the fields to display by specifying them in a list_display property in the admin.py file....
🌐
Django
docs.djangoproject.com › en › 3.1 › howto › › custom-model-fields
Writing custom model fields | Django documentation | Django
We’ll get into the precise details of what Field can do later on; for now, suffice it to say that everything descends from Field and then customizes key pieces of the class behavior. It’s important to realize that a Django field class is not what is stored in your model attributes. The model attributes contain normal Python objects.
🌐
Gaetangrond
gaetangrond.me › posts › storing list in models with django
Storing List in Models with Django | Gaëtan Grond - Personal Website
September 4, 2024 - Fortunately, the django.contrib.postgres.fields module provides an ArrayField that allows you to store lists in a model. This field saves you from writing custom code to serialize and deserialize the list, and it also allows you to query the ...
🌐
Reddit
reddit.com › r/django › how do you put a listfield attribute in a django model?
r/django on Reddit: How do you put a ListField attribute in a Django model?
October 18, 2021 -

I have a model TutorProfile and I wanted it to have an attribute like a list for storing the names of students, so that I will know who are the students that has successfully booked a lesson to a certain tutor. Can someone guide me with this?

this my model

class TutorProfile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='tutor_profile')
    profile_headline = models.CharField(max_length=200, null=True)
    bio = models.TextField(max_length=500, blank=True, null=True)
    is_validated = models.BooleanField(default=False)
    hourly_rate = models.DecimalField(max_digits=8, decimal_places=2, default=0)
    students = models.ListField()
Top answer
1 of 2
7
The approach may depend on the complexity you are looking for. If you have a large roster of students that can each have several tutors, then you would do a thorough data model (later) If a tutor is going to simply track the students who contact them (and there isn't a need for a central master list of students), there would be a second model Tutorship with a foreign key to TutorProfile (with a related_name='students') and a field for the student name and contact information. From a TutorProfile entry, Django will then provide a students accessor that will get you to details or you could do students.count(). For more thorough roster of students you would have another model for Student. Assuming a student could have more than one tutor (one for Math, one for Science), you would have another model Tutorship that contains a foreign key to TutorProfile (related_name='students') and a foreign key to Student (related_name=;tutors'), along with fields to track the start date, and end date. As before, the accessors would be available from either a TutorProfile or from the Student. With either approach, it might be desirable to track the sessions, so you might even have a TrainingSession model, with a foreign key to Tutorship that tracks each session's date (or datetime) and duration, and maybe a note field for what was done in that session. This seems like a lot of models, but it organizes the data into the relationships and allows you to track attributes of those relationships. From a Tutorship model, you can summarize all of the training sessions. It is also possible on the Tutorship to have an agreed hourly_rate (rather than the default hourly rate on the TutorProfile) in situations where the student needs more in-depth help or perhaps only a light review of progress. A good data model supports the business and how the business works, not the nifty shortcuts the programmer devises. I learned this once and it stuck with me and made the application incredibly extendable over the years as there were new attributes (fields) to track on each model but the relationships between the models did not change.
2 of 2
3
If you are never going to need more data on the students and it's really just a list of names you want to have access to or query on, then `from django.contrib.postgres.fields import ArrayField` is a great choice. It's important not to use these too much, for sake of complicating matters down the road if you wind up wanting more metadata on students. Also, you need to be using Postgres.