Django rookie question: models with a variable number of textfields

Greetings all,

Brand new to the framework and community and am stuck on what is likely a simple question.

In building my models, I’m trying to capture as part of a daily journal entry the number of meals consumed and a description of each (textfield). The issue I’m having is every day will bring a different number of meals, generally between zero and 12 (thinking in terms of newborns!).

I am stumped on what the right model field is for a scenario like this. After Googling I found an ArrayField but this didn’t look like the right approach. Curious if any of you all have developed something similar.

Many thanks in advance,

My guess is that you should create another model with a foreign key to original model with a textfield (a many-to-one relationship) to solve your problem.

1 Like

To add to @mdamien’s answer, if you haven’t already done so, I strongly encourage you to work through the official Django Tutorial. If you do, you’ll notice that the Polls app you create is very closely aligned to the type of scenario you’re looking to address here.

1 Like

Thank you, Damien. And Ken, I’ll do the tutorial right away. I certainly appreciate it.