Re: Django call_command from Admin

2022-10-25 Thread Aziz Mek
Hi Mike, Many thanks for the heads and up and confirmation that it can be done, much appreciated Kind regards Aziz On Wednesday, October 26, 2022 at 12:16:00 AM UTC+1 mikeol...@open4businessonline.com wrote: > Aziz, > > I had a similar need and I created my own middleware that checked the >

Re: Django call_command from Admin

2022-10-25 Thread Mike Oliver
Aziz, I had a similar need and I created my own middleware that checked the request path and did the call when I got a match. See https://docs.djangoproject.com/en/4.1/ref/middleware/ *Mike Oliver** Founder**, Open 4 Business Online* Tel: +1(951)260-0793 | Mobile:**NEW* 639479927462 US Toll

Re: Django call_command from Admin

2022-10-25 Thread Aziz Mek
Thank you Mdehs, Much appreciated for the advice, I try to avoid signals as they are thread huggers but maybe i will or try to circumvent them somehow Kind regards Aziz On Friday, October 21, 2022 at 7:32:02 PM UTC+1 mdehs...@gmail.com wrote: > Please refer the signal concept in django you

Re: Django call_command from Admin

2022-10-25 Thread Aziz Mek
Hi Paul, Many thanks for this, much appreciated, I will have a look and try to implement it, will let you know. Kind regards Aziz Meknassi On Monday, October 24, 2022 at 2:03:08 PM UTC+1 pa...@scom.ca wrote: > > you need to basically add a hook (save class) to your save model and > process

Re: Django call_command from Admin

2022-10-24 Thread Paul Kudla
example for admin.py def save_model(self, request, obj, form, change): #This will save create #Check to see if this will be an invoice copy copy = False current_invoice = obj.invoice_number if obj.new_invoice : #clear the flag and save

Re: Django call_command from Admin

2022-10-24 Thread Paul Kudla
you need to basically add a hook (save class) to your save model and process stuff along the way. you will need to modify this example but it's how i update info when saving an scom email user for dovecot. you can also override the admin class as well with something simaliar Note :

Re: Django call_command from Admin

2022-10-21 Thread Mohammad Ehsan Ansari
Please refer the signal concept in django you will get how to implement it On Thu, 20 Oct, 2022, 9:36 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

Re: Django call_command from Admin

2022-10-21 Thread Mohammed Mohamed
Hello there Aziz, are you a beginner in Python? I'm one. Could we make some Google meet arrangements so that I can learn from you. On Thursday, 20 October 2022 at 19:17:41 UTC+3 azi...@gmail.com wrote: > Hi > > Thank you very much for the swift response and for the link, much > appreciated.

Re: Django call_command from Admin

2022-10-20 Thread Muhammad Juwaini Abdul Rahman
https://docs.djangoproject.com/en/4.1/ref/django-admin/#running-management-commands-from-your-code I think it's quite straightforward. Just add call_command(command) after (or before the save() line) in your code. Depending on whether you're using FBV or CBV, you need to pinpoint where exactly

Re: Django call_command from Admin

2022-10-20 Thread Aziz Mek
Hi Tega, Nice to meet you and apologies for the delay in getting back to you, Signals are both the best and worst. Yes, they'd "solve" this problem. Though so would overriding the model's save method or the admin's save method. But the issue I find with them is that because they are

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.

Re: Django call_command from Admin

2022-10-20 Thread Aziz Mek
Hi Thank you very much for the swift response and for the link, much appreciated. I did have a look at that article this morning but it is using signals which will only add one more layer to my stack and i think essentially does what call_command will do anyway. I really appreciate your

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,