def user_list(request): context = RequestContext(request) if request.method == 'POST': form = forms.FindUserForm(request.POST) if form.is_valid(): username = form.cleaned_data.get('username') try: user = models.User.objects.get(username=username) return redirect('kegadmin-edit-user', user.id) except models.User.DoesNotExist: messages.error(request, 'User "%s" does not exist.' % username) users = models.User.objects.exclude(username='******').order_by('-id') paginator = Paginator(users, 25) page = request.GET.get('page') try: users = paginator.page(page) except PageNotAnInteger: users = paginator.page(1) except EmptyPage: users = paginator.page(paginator.num_pages) context['users'] = users return render_to_response('kegadmin/user_list.html', context_instance=context)
def user_list(request): context = {} if request.method == "POST": form = forms.FindUserForm(request.POST) if form.is_valid(): username = form.cleaned_data.get("username") try: user = models.User.objects.get(username=username) return redirect("kegadmin-edit-user", user.id) except models.User.DoesNotExist: messages.error(request, 'User "%s" does not exist.' % username) users = models.User.objects.exclude(username="******").order_by("-id") paginator = Paginator(users, 25) page = request.GET.get("page") try: users = paginator.page(page) except PageNotAnInteger: users = paginator.page(1) except EmptyPage: users = paginator.page(paginator.num_pages) context["users"] = users return render(request, "kegadmin/user_list.html", context=context)