I am trying to add a field that would let me add multiple show dates in a Django Model. Sometimes the show date will contain 3 dates, sometimes 1 or sometimes 7. How am I able to add this in a model and have it so I can add multiple dates in the Django admin?
1 Answer
If you are using postgres you can use an ArrayField for this purpose.
from django.db import models
from django.contrib.postgres.fields import ArrayField
class MyModel(models.Model):
dates = ArrayField(
models.DateTimeField(),
)
Here is the documentation
An alternate approach would be to declare a ShowDate model and set a ForeignKey linking back to your Show model.