2

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 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.