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 
> 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 <(951)%20260-0793> | Mobile:**NEW* 639479927462
> US Toll free: 1-800-985-4766 <(800)%20985-4766> **NEW*
> http://www.o4bo.com
> Mas marunong akong umunawa ng salitang tagalog kaysa magkapagsalita nito 
> [image: Facebook] 
>  
> [image: 
> Twitter]  [image: LinkedIn] 
>  [image: AngelList] 
>  [image: Blogger] 
>  [image: eBay] 
>  [image: YouTube] 
>  [image: Google 
> Plus Page] 
> Contact me: [image: Google Talk] mikeol...@open4businessonline.com [image: 
> Skype] MikeOliverAZ
>
>
>
> On Fri, Oct 21, 2022 at 12:06 AM 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...@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/1de3fda8-162e-4b83-b740-b65cea41eaf4n%40googlegroups.com.


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 free: 1-800-985-4766 **NEW*
http://www.o4bo.com
Mas marunong akong umunawa ng salitang tagalog kaysa magkapagsalita nito
[image: Facebook]
 [image:
Twitter]  [image: LinkedIn]
 [image: AngelList]
 [image: Blogger]
 [image: eBay]
 [image: YouTube]
 [image: Google
Plus Page] 
Contact me: [image: Google Talk] mikeolive...@open4businessonline.com [image:
Skype] MikeOliverAZ



On Fri, Oct 21, 2022 at 12:06 AM 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/CAA2yvOHvP_fWa4cptWxVdjt7UQELPM60LetC-fSBnXhTxivSWA%40mail.gmail.com.


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 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 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...@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/d972e95f-090f-4c24-acbc-7f75273dd439n%40googlegroups.com.


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 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 :
> super(EmailUsers, self).save(*args, **kwargs) #Save the email changes
>
> is extemely important as stuff will process but any field updates will 
> not save without the above line..
>
> example :
>
>
> def save(self, *args, **kwargs): #This will create an email account if 
> nessesary.
> emailaddress = str(self.username) #Set the email address to see if we 
> need to create the mailbox?
> emailpassword = str(self.password) #Set the password (used for check 
> alias)
>
> #prefill username/domain is blank
> if self.domain == None or str(self.domain) == '' :
> self.domain = self.username.split('@')[1]
>
> if self.source == None or str(self.source) == '' :
> self.source = self.username
>
> if self.destination == None or str(self.destination) == '' :
> self.destination = self.username
>
>
>
>
> domain = str(self.domain)
> send_settings = str(self.send_settings)
> if self.send_settings == None :
> send_settings = ''
> self.send_settings = ''
> dontupdate = self.dontupdate
> self.dontupdate = False
>
> #set dovecot directory & split user / domain
> if self.username.split('@')[1] == 'preload.scom.ca' :
> self.home = '/data/dovecot/users/%s/%s' %( 
> self.domain,self.destination.split('@')[0] )
> else:
> self.home = '/data/dovecot/users/%s/%s' %( self.domain,self.destination )
>
> self.user = self.username.split('@')[0]
>
> #Set alias Flag
> if self.password == 'alias' or (self.source != self.destination) :
> self.alias_flag = True
> #self.sieve_forwards = ''
> #self.vacation_active = False
> else :
> self.alias_flag = False
>
> self.username_search = self.username
> self.username_search = self.username_search.replace ('.','')
> self.username_search = self.username_search.replace ('@','')
>
>
> super(EmailUsers, self).save(*args, **kwargs) #Save the email changes
>
> i email with something like :
>
> #Try to get info for this account
> if dontupdate == False :
>
> imap_test = Dovecot_Command ('INFO',self.username) #do i have this 
> account ?
>
> if 'BAD' in imap_test.answer :
> try : #Try to Create the account, note that the db must be updated 
> properly before it will work
> imap_create = Dovecot_Command ('CM',self.username)
> if 'OK' in imap_create.answer :
> send_subject = 'Email Account Created : %s' %(str(self.username) )
>
> except :
> send_subject = 'Error Account : %s' %(str(self.username) )
> pass
>
> else :
> send_subject = 'Email Account Updated : %s' %(self.username)
>
> #Send update email
>
> send_from = 'mon...@scom.ca'
> send_files = []
> send_to = ['mon...@scom.ca'] 
> send_text = '\n\n'+ send_subject + '\n'
> sendmail(send_from,send_to,send_subject,send_text,send_files) #Send 
> the warning email
>
>
>
>
> Happy Monday !!!
> Thanks - paul
>
> Paul Kudla
>
>
> Scom.ca Internet Services 
> 004-1009 Byron Street South
> Whitby, Ontario - Canada
> L1N 4S3
>
> Toronto 416.642.7266 <(416)%20642-7266>
> Main 1.866.411.7266 <(866)%20411-7266>
> Fax 1.888.892.7266 <(888)%20892-7266>
> Email pa...@scom.ca
>
> On 10/21/2022 2:30 PM, Mohammad Ehsan Ansari wrote:
> > 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 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...@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 

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 the current object then 
set new & date

obj.new_invoice = False
obj.save()
copy = True




Happy Monday !!!
Thanks - paul

Paul Kudla


Scom.ca Internet Services 
004-1009 Byron Street South
Whitby, Ontario - Canada
L1N 4S3

Toronto 416.642.7266
Main 1.866.411.7266
Fax 1.888.892.7266
Email p...@scom.ca

On 10/20/2022 12:05 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 .


--
This message has been scanned for viruses and
dangerous content by *MailScanner* , and is
believed to be clean.


--
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/c1f3567f-e13c-0a12-4f5e-ce0af7eaf115%40scom.ca.


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 :
super(EmailUsers, self).save(*args, **kwargs)  #Save the email changes

is extemely important as stuff will process but any field updates will 
not save without the above line..


example :


	def save(self, *args, **kwargs): #This will create an email account if 
nessesary.
		emailaddress = str(self.username) #Set the email address to see if we 
need to create the mailbox?
		emailpassword = str(self.password) #Set the password (used for check 
alias)


#prefill username/domain is blank
if self.domain == None or str(self.domain) == '' :
self.domain = self.username.split('@')[1]

if self.source == None or str(self.source) == '' :
self.source = self.username

if self.destination == None or str(self.destination) == '' :
self.destination = self.username




domain = str(self.domain)
send_settings = str(self.send_settings)
if self.send_settings == None :
send_settings = ''
self.send_settings = ''
dontupdate = self.dontupdate
self.dontupdate = False

#set dovecot directory & split user / domain
if self.username.split('@')[1] == 'preload.scom.ca' :
			self.home = '/data/dovecot/users/%s/%s' %( 
self.domain,self.destination.split('@')[0] )

else:
self.home = '/data/dovecot/users/%s/%s' %( 
self.domain,self.destination )

self.user = self.username.split('@')[0]

#Set alias Flag
if self.password == 'alias' or (self.source != 
self.destination) :
self.alias_flag = True
#self.sieve_forwards = ''
#self.vacation_active = False
else :
self.alias_flag = False

self.username_search = self.username
self.username_search = self.username_search.replace ('.','')
self.username_search = self.username_search.replace ('@','')


super(EmailUsers, self).save(*args, **kwargs)  #Save the email 
changes

i email with something like :

#Try to get info for this account
if dontupdate == False :

			imap_test = Dovecot_Command ('INFO',self.username) #do i have this 
account ?


if 'BAD' in imap_test.answer :
try : #Try to Create the account, note that the db must be updated 
properly before it will work

imap_create = Dovecot_Command 
('CM',self.username)
if 'OK' in imap_create.answer :
send_subject = 'Email Account 
Created : %s' %(str(self.username) )

except :
send_subject = 'Error Account : %s' 
%(str(self.username) )
pass

else :
send_subject = 'Email Account Updated : %s' 
%(self.username)

#Send update email

send_from = 'moni...@scom.ca'
send_files = []
send_to = ['moni...@scom.ca']   
send_text = '\n\n'+ send_subject + '\n'
			sendmail(send_from,send_to,send_subject,send_text,send_files) #Send 
the warning email





Happy Monday !!!
Thanks - paul

Paul Kudla


Scom.ca Internet Services 
004-1009 Byron Street South
Whitby, Ontario - Canada
L1N 4S3

Toronto 416.642.7266
Main 1.866.411.7266
Fax 1.888.892.7266
Email p...@scom.ca

On 10/21/2022 2:30 PM, Mohammad Ehsan Ansari wrote:

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

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 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/CAF8ux6Li0BjKS2zvQuPWL6zq-R6Buo9wa1fBx68m4ESpTptHug%40mail.gmail.com.


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.
>
> 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 response
>
> PS: I couldn't see your name in the email hence why I didn't address you 
> by it, apologies
>
> Kind regards
> Aziz 
> On Thursday, October 20, 2022 at 5:10:04 PM UTC+1 justt...@gmail.com 
> wrote:
>
>> 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...@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/accaca49-b8dc-484b-a4de-9e5c78395902n%40googlegroups.com.


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 the save() function resides in your code.

On Fri, 21 Oct 2022 at 00:05, 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/CAFKhtoR2mPPMVD%3DpALF1oB%3DiKZqFL93NCodm3k3J9C%2BBdAkgjQ%40mail.gmail.com.


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 decoupled from the 
model in a year, or the next dev, someone won't have a clue why an email is 
being sent or how to troubleshoot it.

My general guideline for using them is as a last resort. They are the lazy 
way of solving problems but will almost always cause different problems in 
the future.

Also you now have to be keenly aware of the circumstances where signals 
don't fire, also signals in my case will block the thread as the number of 
subscribers is big, 

Please let me know if you have different point of view, i am not dismissing 
any opinions


the management command is already written by another developer and i am 
trying to leave as few footprint in the code as I can, I am not even sure

if it is the right way to go about this. 

Will let you know how it pans out if you want.


Kind regards

Aziz Meknassi

On Thursday, October 20, 2022 at 5:30:21 PM UTC+1 justt...@gmail.com wrote:

> 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...@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/ac2cb103-5f51-47bf-9fc7-a949bcd6d312n%40googlegroups.com.


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

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

PS: I couldn't see your name in the email hence why I didn't address you by 
it, apologies

Kind regards
Aziz 
On Thursday, October 20, 2022 at 5:10:04 PM UTC+1 justt...@gmail.com wrote:

> 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...@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/e2260a1a-e1cb-4a6c-9538-c9a3501d8acbn%40googlegroups.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.