If I understand your predicament correctly, the problem itself is how you deal with which categories may be parents and which may not. One way to avoid these problems is to actually limit the level of categories that can become parents. For example, let's say you have the following categories:
As I usually deal with this, I obviously have a parent_id FK in the category table. For root elements (Internet, Offline), the parent identifier will be 0. So, when you try to find the "parent categories" for the drop-down list, you need to decide how far they can hold the nesting. I basically limit this to the first level, so to select the categories that will be displayed in the drop-down list, you would do something like:
parents = Category.objects.filter(parent_id=0)
Now it’s obvious that this limits the approach a bit, but you can increase the level you want to include and develop some kind of visual identification system for the drop-down list in your template (including additional spaces or dashes for each level in the hierarchy or something else) .
In any case, sorry for the long answer, and hopefully this has somewhat affected your problem.
David source share