Re: Django call_command from Admin

2022-10-20 Thread Tega Ukavwe
The name's Tega,

If I may ask you, what makes you favour making a management command as
opposed to creating a simple post_save signal in your present situation.

>From the django documentation, post_save is literally called on every save,
something similar to the Publisher Subscriber pattern.

I'd really appreciate your response on this.

Regards,
Tega Ukavwe
Python Like English

On Thu, Oct 20, 2022 at 5:06 PM Aziz Mek  wrote:

> Hi All,
>
> I was wondering  if you have come across the following:
>
> I have a field in the model that's empty, when the user fills it up and
> clicks Save, it
> should trigger/call a management Command (This command is already build
> that sends emails ), Django docs say i can use call_command but not sure
> how to implement it with the save
>
> I am just after the trigger really when the save takes place
>
> Many thanks in advance
>
> Kind regards
> Aziz
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a0ca69f0-6065-4b86-a977-cfb6dcab8fd7n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a0ca69f0-6065-4b86-a977-cfb6dcab8fd7n%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BbC3qX6pyE2ofQ4%2B5v00wv86yKUH_di44S3iP7M078NWnqrPQ%40mail.gmail.com.


Re: Django call_command from Admin

2022-10-20 Thread Tega Ukavwe
Do a little read up on post_save signal.

Below is a link to a good start point for you:
https://simpleisbetterthancomplex.com/tutorial/2016/07/28/how-to-create-django-signals.html

I hope this helps you in your search.
Best Wishes Aziz.

On Thu, Oct 20, 2022 at 5:06 PM Aziz Mek  wrote:

> Hi All,
>
> I was wondering  if you have come across the following:
>
> I have a field in the model that's empty, when the user fills it up and
> clicks Save, it
> should trigger/call a management Command (This command is already build
> that sends emails ), Django docs say i can use call_command but not sure
> how to implement it with the save
>
> I am just after the trigger really when the save takes place
>
> Many thanks in advance
>
> Kind regards
> Aziz
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a0ca69f0-6065-4b86-a977-cfb6dcab8fd7n%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BbC3qVps1VGXC%3DOHnNzCrUG2kcJZ21uRbgC1a08q-11_7ckBw%40mail.gmail.com.


Re: Is there a way to pass arbitrary argument from serializer.save to model.save method

2022-09-24 Thread Tega Ukavwe
Hello Sencer,
You could override the serializer class' create method.

https://www.django-rest-framework.org/api-guide/serializers/#saving-instances

Hope this helps you mate.

Cheers,
Tega Ukavwe
Python Like English

On Fri, Sep 23, 2022 at 7:21 PM Sencer Hamarat 
wrote:

> Hi,
>
> I need to pass an arbitrary argument from the serializer.save() method to
> model.save() method?
>
> Such as:
>
> serialized_data = AModelSerializer(instance, data=adata_dict)
> if serialized_data.is_valid():
> serialized_data.save(an_arg="value")
>
> class Amodel(models.Model)
> def save(*args, **kwargs):
>  extra_arg = kwargs["an_arg"]
>
>
> The method demonstrated above is not working due to nature of serializer.
> Bu I can't figure out any other way to do that.
>
> Right now, I'm open to suggestions.
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACp8TZjF3_eQ6KSQKnatVHQGQsh%3Dz6Kr4pdVEM151VbnSq5N1g%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CACp8TZjF3_eQ6KSQKnatVHQGQsh%3Dz6Kr4pdVEM151VbnSq5N1g%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BbC3qVJw0x5KZtToCrvai5n6acjOFaAch%2BQGzrkSyxn3Fp9-A%40mail.gmail.com.