I’ve finished the Django tutorial, and thought I could jump into a basic aspect of my project for now to get started. But I’m getting really overwhelmed and could use some pointers.
So this part of the app is basically a tool to add json data to a longtext field in the database for a given row. This json would be a two level nested structure, like this example:
{
"people": [
{
"name": "Alice",
"age": 30,
"books": [
{
"title": "To Kill a Mockingbird",
"author": "Harper Lee",
"year": 1960
},
{
"title": "1984",
"author": "George Orwell",
"year": 1949
}
]
},
{
"name": "Bob",
"age": 25,
"books": [
{
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"year": 1925
},
{
"title": "Brave New World",
"author": "Aldous Huxley",
"year": 1932
}
]
}
]
}
What I envisioned was a page that starts with a form for one person and one book for that person. And there would be buttons to add more people and a button under each person for adding more books. Then submitting it to a view, and having Python turn it into JSON to save to the database. And also being able to load already created JSON to populate such forms.
Possibly in the future, I would store people and books as models to be able to select from already existing options or add new ones. But for now, I’m okay with just Forms to input raw text.
The way I did this before hoping to make a more polished Django project was a simple Python script. It would just keep prompting for all the data in a couple nested while loops, which worked okay, but I want something more capable.
It has been a huge mess trying to come up with a solution. I don’t know whether to use Forms or Formsets. I absolutely hate Javascript. I’ve never worked with any JS frameworks, so I’m not sure if that would help. Can anyone point me in the right direction?