Model.delete doesn't take any arguments other than "using". If you
want to pass more context, you'll have to override Model.delete in
your project, create your own signal, and then pass the extra
arguments to it. Same with QuerySet.delete if you want to override
mass deletion also.

Or, even though people on here hate this, you can also store the user
in a thread local variable. For example, using this module (untested,
but theoretically correct):
https://gist.github.com/sbutler/5157265aa97bba665349

with setctxt(deleted_by=someone):
    Car.objects.get(pk=1).delete()

@receiver(post_delete, sender=Car)
def ref_person(sender, instance, **kwargs):
    who_deleted = getctxt('deleted_by', None)

On Wed, May 13, 2015 at 6:36 PM, Neto <paulosouzamac...@gmail.com> wrote:
> I want to pass an argument to delete an object, that argument will be
> handled by the signal.
>
> Car.objects.get(pk=1).delete(deleted_by=someone)
>
>
> models:
>
> @receiver(post_delete, sender=Car)
>
> def ref_person(sender, instance, **kwargs):
>
>     who_deleted = ?
>
>
>
> How do I get this argument?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3ed8e143-7dbd-4de1-ad6f-3b54e12cefca%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxWtj67OLg_EtHLkqL1sOrfZvMjw8Kyzpi5Lpud1%3DveS3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to