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
-~----------~----~----~----~------~----~------~--~---

Reply via email to