python - Query to filter by alphabetic order -


template.html is

{% field in types%}  {{field}}<br /> {% endfor %} 

i tried sort out list in alphabetic order.used type_list = types.objects.filter(user=user.id, parent_type_id=true).order_by('title') in above view sort.i don't know whether queried right.it not giving error,but function not happening.need help.

thanks

if want order alphabetically form's choices, have modify query them, inside form, not in views, modify line in __init__ method of form this:

def __init__(self, type_id, *args, **kwargs):     ...     type = types.objects.filter(parent_type_id=type_id).order_by('title')     my_choices=((type.id, type.title) type in type)     _type_checkbox.choices = my_choices     ... 

hope helps!


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -