Hi everybody, I'm writing my first app with Django (quite a newbie with python too) and I stumbled onto the following problem: I have a template which has to regroup a object_list by a field that the user has determined by choosing it in a <select> tag of a form. So, what I pass via extra_context to the template is actually the string name of the field, but I'm afraid the regroup syntax expects not this name, but the field itself. How can I call it from the name?
excerpt of the view: def do_smpSearch(request): ... my_order_by = request.POST['my_order_by'] ... p = Docs.objects.filter(clause) if my_order_by: p = p.order_by(my_order_by) ... return list_detail.object_list( request = request, queryset = p, template_name = "docum/docs_list.html", extra_context = {"regr_factor" : my_order_by,} ) ******** excerpt of the template: {% if regr_factor %} {% regroup object_list by regr_factor as grouped %} <-- BAD syntax <ul> {% for group in grouped %} <li>{{ group.grouper }} <ul> {% for item in group.list %} <li><a href="{{ item.get_absolute_url }}">{{ item }}</a></ li> {% endfor %} </ul> </li> {% endfor %} </ul> {% else %} ... Further (related) problem: I saw in a prievious post (http:// groups.google.com/group/django-users/browse_thread/thread/ 3f85b80427df29d8/75192f4ed0f67c55? lnk=gst&q=regroup&rnum=7#75192f4ed0f67c55) that if the field I want to regroup by contains choices, instead of the field a "get_FIELD_display" should be passed as "by" argument in the regroup syntax. Then, supposed I find out a way to determine field objects from their name, I should also verify if they have choices inside... Any hint? Thank you 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-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---