0👍
✅
Tested it and the solution is really simple.
With g=Activity.objects.filter(groups__in=[Group.objects.filter(group_nm=group_nm)],enddt__gt=now)
you put an iterable in a list ([QuerySet]
) which django doesn’t know how to index.
The solution is to dump the list comprehension:
g=Activity.objects.filter(groups__in=Group.objects.filter(group_nm=group_nm),enddt__gt=now)
and then it works like a charm.
1👍
I think what you want to do is filter the activity_set
(see backward relations) from the group specified by group_nm
:
def group_details_page(request, group_nm):
group_instance = Group.objects.get(group_nm=group_nm)
activities = group_instance.activity_set.objects.filter(enddt__gt=now)
return render_to_response(...etc...)
- [Answer]-Django Tastypie Reference the Same ForeignKey Model More Than Once
- [Answer]-No admin styles after following tutorial
- [Answer]-Django, how to display data with space in input box?
- [Answer]-Uniqueness depends on only one-to-one relationship
- [Answer]-Get value from tuple of tuples in Django template
Source:stackexchange.com