Reputation: 69
I have a Subject model, and every subject needs a schedule, so I want to have a list of datetimes in the model. I know that postgres has a ArrayField method but I'm using SQLite3.
class Subject(models.Model):
name = models.CharField()
schedule = #Here I need the list of datetimes
It's a short question but I didn't find anything like this
Upvotes: 0
Views: 247
Reputation: 544
You can't put something like a ListField
inside an SQLite3 model. But you can by using foreign keys and another model:
class Schedule():
subject=models.ForeignKey(Subject, on_delete=models.CASCADE)
data=...
And
all_schdules=subject.schdule_set.all()
Upvotes: 1