Dear all, Thanks for your reply I have modified my code as per below : views.py : def display_delete_profile(request): user = request.user if user.is_superuser: user_list = User.objects.all() return render_to_response ('delete.html', {'user_list':user_list})
def delete (request): user = request.user if user.is_superuser: if request.method == 'POST': form = DeleteForm(request.POST) if form.is_valid: username = form.cleaned_data['username'] user_delete = User.objects.get(username=username) id_delete = user_delete.id return delete_object(request,object_id = id_delete, model=User, post_delete_redirect='/notify/success/', template_name='delete.html',login_required=True) else : form = DeleteForm() variables = RequestContext(request, {'form' : form}) return render_to_response('delete.html',variables) forms.py: class DeleteForm(ModelForm): class Meta : model = User fields = ('username',) template: <h1> Delete User </h1> <br> <p> Please select username below for delete profile </p> <br> <form id ="delete" method="POST" action="/accounts/delete/done/ "> <p> username : <select name ="delete_user"> <option value = "delete"> Please select as the default item in the list</option> {% for user in user_list %} <option value = {{ user.id }}> {{ user.username }} </option> {% endfor %} </select> </p> <p><input type="submit" value="delete"></p> </form> the display_delete_profile run fine and exactly like I want, but delete always raise error "The view fintoo.apps.authorization.views.delete didn't return an HttpResponse object." I have google it and by example provided it relate to indentation matters when put template renderer. but I think I don't have any problem with that. please put some light and really appreciate for any kind help. Thank you. regards, -vierda- On Jan 29, 5:41 pm, Malcolm Tredinnick <malc...@pointy-stick.com> wrote: > On Wed, 2009-01-28 at 23:47 -0800, Daniel Roseman wrote: > > [...] > > > No, you have provided four keyword arguments. The signature for the > > delete_object function is as follows: > > def delete_object(request, model, post_delete_redirect, > > object_id=None, > > slug=None, slug_field='slug', template_name=None, > > template_loader=loader, extra_context=None, > > login_required=False, > > context_processors=None, template_object_name='object'): > > > So you need to pass request, model and post_delete_redirect *without* > > keywords, as simple positional arguments: > > return delete_object(request, User, '/notify/delete_done/', > > template_name='delete.html', login_required=True) > > Everything you've written is correct, except for this bit. You > emphasised the word "without" and that's not necessary. If a Python > function has this signature: > > def foo(a, b, c=None, d=6): > ... > > then you can quite happily use keyword arguments for the 'a' and 'b' > parameters. What is different about those parameters is that you *must* > supply them. They don't have default values. So foo(c=6, a=1, b='fred') > would be a valid way to call that function. > > The Python error message is slightly misleading here (and it is > generated by Python, not by Django). What they mean is that it takes two > required arguments. By definition (Python's syntax requires it), the > required arguments have to come before any default arguments, so they > can be passed in as positional arguments. But the keyword/non-keyword > argument distinction is actually a bit misleading in this case. > > Regards, > Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---