Basically, I am making a django application which is something like a Todo List.Each item in the Todo list has a list of their own.For eg. if I have items A,B,C,D in the todo list then each item has their own lists inside of them. Moreover I want to make A,B,C,D such that I can go from each item in the todo list to a menu/listings page and then select items for them from the menu/listings page. I am stuck on the second part and confused on how to proceed.
Asked
Active
Viewed 38 times
0
-
See https://stackoverflow.com/questions/15285626/django-self-referential-foreign-key – Selcuk Jun 10 '19 at 05:10
-
Do you mean, you have some items such as A, B, C, D. And inside the items, you have a list such as inside A you have (a,b,c,d,e,f,......) Is it? – Fatema Tuz Zuhora Jun 10 '19 at 06:41
-
yes,the list should be such that A has elements (a,b,c), B has (d,b,a,e) and so on – Ahmad Javed Jun 10 '19 at 07:28
-
Don't you think that 2 class (models) joined by a One-to-One relationships (or Many-to-One) can solve your problem ? Have a look on Django documentation here : https://docs.djangoproject.com/en/2.2/topics/db/examples/one_to_one/ – Bea Jun 10 '19 at 09:11
-
Here is an exemple : https://medium.com/fbdevclagos/how-to-build-a-todo-app-with-django-17afdc4a8f8c – Bea Jun 10 '19 at 09:14
-
I also followed the same approach and created 2 models joined by Many-to-One relation however I am confused about how to create the views function for the same. – Ahmad Javed Jun 10 '19 at 09:14