def get_queryset(self): try: search_term = self.request.GET['q'] users = find_users(name=search_term)[:5] except KeyError: users = User.objects.filter(is_active=True) return [user_json(u) for u in users]
def get_queryset(self): try: search_term = self.request.GET['q'] users = find_users(name=search_term) except KeyError: users = User.objects.all() return [{"name": u.get_full_name(), "id": u.id, "profile": reverse('view_profile', args=(u.pk,))} for u in users]
def get_queryset(self): try: search_term = self.request.GET['q'] users = find_users(name=search_term)[:5] except KeyError: users = User.objects.all() return [user_json(u) for u in users]
def to_python(self, value): if value is None: return None user = find_users(value).first() if user is None: try: validate_email(value) return User(email=value) except ValidationError: raise forms.ValidationError("No user matching query '{}'".format(value)) return user
def get_queryset(self): try: search_term = self.request.GET['q'] users = find_users(name=search_term) except KeyError: users = User.objects.all() return [{ "name": u.get_full_name(), "id": u.id, "profile": reverse('view_profile', args=(u.pk, )) } for u in users]
def to_python(self, value): if not value: return None user = find_users(value).first() if user is None: try: validate_email(value) return User(email=value) except ValidationError: raise forms.ValidationError("No user matching query '{}'".format(value)) return user
def get_queryset(self): search_term = self.request.GET['q'] items = [] most_of_each = 5 users = find_users(name=search_term)[:most_of_each] items += [user_json(u) for u in users] projects = Project.objects.filter(Project.filter_can_be_viewed_by(self.request.user)).filter(name__icontains=search_term)[:most_of_each] for p in projects: items.append({ 'id': p.pk, 'profile': reverse('project_index',args=(p.pk,)), 'name': p.name, 'autocomplete_entry': get_template('autocomplete/project.html').render({'project':p}), }) return items