I am building an app that displays different courses. For each course there is a list of the different classes it has. Some courses have two classes, some have eight, some have just one or in the future some courses may have 10 classes. It's up to the app's administrator when they register a new course
class Curso(models.Model):
clases = models.IntegerField(default=1)
content = ArrayField(models.CharField(max_length=30),blank=False)
This model will only be for the administrator.
I want to store the different classes (just their names) in an array. But there's no need to show 8+ fields if the admin is just going to fill one in... Or is that the correct approach?
I want the admin to have an integer field where she types in how many classes the course has and depending on that the array fields will be displayed.
I understand ArrayField
has a size attribute where I can say how long the array is. Right? So my question is:
Is there a way to dynamically change the array size depending on what the admin types in in the "clases" field?
I need this to work in the admin app. I am new to Django and I'm finding the admin app a little bit hard to manipulate.