First a short description of the issue:

I'm trying to create a module-system similar to the one in Joomla!,
where modules (small information-widgets) can be shown in different
positions on different pages of the website.
I'm using the django-treemenus app for the menu-structure of the
website, this is comprised of two models: Menus and MenuItems.

When the user creates a module in the Django-admin he should be able
to pick the pages it's shown on from a SelectMultiple-list. For this,
I've created a Many-to-Many field that links Modules with MenuItems.
So far so good.

The MenuItems are shown ordered by ID, as is to be expected. However,
I would like to show them ordered by Menu, and also indented according
to their level in the tree-structure. The MenuItems-model contains
methods to generate such a structure, I just don't know what the best
way to populate the SelectMultiple-field with it is. After some
googling and searching in this group, I think I've found two possible
solutions:

1. Create a custom-widget based on SelectMultiple and replace
self.choices with my own tuples. The problem I see with this is that
it will query the database unnecessarily, once to populate the field
in the default way and then when I run my own queries. Is there a way
to avoid this? Where are the choices generated?

2. Instead of a Many-to-Many field, maybe use some other field
(CommaSeparatedInteger?) and make a ModelForm that shows a
MultipleSelect-Widget that I populate dynamically. The problem here is
that I'd rather prefer not to lose the relationship between Modules
and MenuItems that the M-to-M field creates.

Sorry for this lengthy first post. Anybody have any idea what the best
solution is? Is there something I haven't considered?
Thanks in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to