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]
<http://www.facebook.com/pages/Open-4-Business-Online/147285608707176> [image:
Twitter] <https://twitter.com/O4BO> [image: LinkedIn]
<http://ph.linkedin.com/pub/mike-oliver/0/1b9/197> [image: AngelList]
<https://angel.co/open-4-business-online/> [image: Blogger]
<http://blog.open4businessonline.com/> [image: eBay]
<http://www.store.o4bo.com/servlet/StoreFront> [image: YouTube]
<http://www.youtube.com/channel/UCruaIEFosh9uvfkQCq7mtKw> [image: Google
Plus Page] <https://plus.google.com/113688478700619104336/posts>
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
> <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/CAA2yvOHvP_fWa4cptWxVdjt7UQELPM60LetC-fSBnXhTxivSWA%40mail.gmail.com.


Re: Can an app subclass a core django class to channge its behavior

2022-08-25 Thread Mike Oliver
Ok will try the shell


On Thursday, August 25, 2022 at 2:00:33 PM UTC+8 bboy...@gmail.com wrote:

>
> Ur config with me are the same.
>
> [image: Screenshot_2022-08-25-12:50:38-1661406638.png]
> But i put it in the bottom of the middleware
>
> MIDDLEWARE = [
> "django.middleware.security.SecurityMiddleware",
> "whitenoise.middleware.WhiteNoiseMiddleware",
> "django.contrib.sessions.middleware.SessionMiddleware",
>
> "django.middleware.common.CommonMiddleware",
> "django.middleware.csrf.CsrfViewMiddleware",
> "django.contrib.auth.middleware.AuthenticationMiddleware",
> "django.contrib.messages.middleware.MessageMiddleware",
> "django.middleware.clickjacking.XFrameOptionsMiddleware",
>
> "chuthe.middlewares.supervisor.ChutheIOMiddleware",
> ]
>
> Think you should try by shell to make sure you can call it, or importable 
> `from mysite.mymiddleware import DoseControllerMiddleware`. Shell very 
> helpful.
> On Thu, Aug 25, 2022 at 11:09 AM Mike Oliver <
> mikeol...@open4businessonline.com> wrote:
>
>> Currently, I have 
>> /mysite/
>> mymiddleware.py
>>settings.py
>>
>> My CustomMiddlware class looks like...
>> class DoseControllerMiddleware(object):
>>
>> def process_request(self, request):
>> """
>> get ready to call the Dose Controller
>> """
>> print("DoseControllerModdleware.process_request Hooray")
>> return None
>>
>> my settings has...
>> MIDDLEWARE = [
>> 'django.middleware.security.SecurityMiddleware',
>> 'django.contrib.sessions.middleware.SessionMiddleware',
>> 'mysite.mymiddleware.DoseControllerMiddleware',
>> 'django.middleware.common.CommonMiddleware',
>> 'django.middleware.csrf.CsrfViewMiddleware',
>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> 'django.contrib.messages.middleware.MessageMiddleware',
>> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>> ]
>>
>> runserver gives me...
>>
>> ModuleNotFoundError: No module named 'mysite.mymiddleware'
>>
>>
>>
>> On Thursday, August 25, 2022 at 12:04:55 PM UTC+8 Mike Oliver wrote:
>>
>>> Well I have continued to search and now I see that CustomMiddleware will 
>>> do what I want, but I cannot find a current example and some of the 
>>> StackOverflow answers are old and not working in the latest Django.
>>>
>>> On Thursday, August 25, 2022 at 10:23:41 AM UTC+8 bboy...@gmail.com 
>>> wrote:
>>>
>>>> Could you tell us more detail of process flow?
>>>>
>>>> On Wed, 24 Aug 2022 at 20:52 Mike Oliver <
>>>> mikeol...@open4businessonline.com> wrote:
>>>>
>>>>> Hello, 
>>>>>
>>>>> I want to follow a microservices architecture and have some shared 
>>>>> services I can include in a process flow instead of the 1:1 View:Model 
>>>>>
>>>>> Suggestions?
>>>>>
>>>>> MO
>>>>>
>>>>> -- 
>>>>> 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/fea12690-f86e-4761-9aef-5be7358dea57n%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/django-users/fea12690-f86e-4761-9aef-5be7358dea57n%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...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/a907da19-4a73-41c5-964d-67b0e67e91e5n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/a907da19-4a73-41c5-964d-67b0e67e91e5n%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/98f04efc-daa3-4403-9b03-bd3942c2ac2fn%40googlegroups.com.


Re: Can an app subclass a core django class to channge its behavior

2022-08-24 Thread Mike Oliver
Currently, I have 
/mysite/
mymiddleware.py
   settings.py

My CustomMiddlware class looks like...
class DoseControllerMiddleware(object):

def process_request(self, request):
"""
get ready to call the Dose Controller
"""
print("DoseControllerModdleware.process_request Hooray")
return None

my settings has...
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'mysite.mymiddleware.DoseControllerMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

runserver gives me...

ModuleNotFoundError: No module named 'mysite.mymiddleware'



On Thursday, August 25, 2022 at 12:04:55 PM UTC+8 Mike Oliver wrote:

> Well I have continued to search and now I see that CustomMiddleware will 
> do what I want, but I cannot find a current example and some of the 
> StackOverflow answers are old and not working in the latest Django.
>
> On Thursday, August 25, 2022 at 10:23:41 AM UTC+8 bboy...@gmail.com wrote:
>
>> Could you tell us more detail of process flow?
>>
>> On Wed, 24 Aug 2022 at 20:52 Mike Oliver <
>> mikeol...@open4businessonline.com> wrote:
>>
>>> Hello, 
>>>
>>> I want to follow a microservices architecture and have some shared 
>>> services I can include in a process flow instead of the 1:1 View:Model 
>>>
>>> Suggestions?
>>>
>>> MO
>>>
>>> -- 
>>> 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/fea12690-f86e-4761-9aef-5be7358dea57n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/fea12690-f86e-4761-9aef-5be7358dea57n%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/a907da19-4a73-41c5-964d-67b0e67e91e5n%40googlegroups.com.


Re: Can an app subclass a core django class to channge its behavior

2022-08-24 Thread Mike Oliver
Well I have continued to search and now I see that CustomMiddleware will do 
what I want, but I cannot find a current example and some of the 
StackOverflow answers are old and not working in the latest Django.

On Thursday, August 25, 2022 at 10:23:41 AM UTC+8 bboy...@gmail.com wrote:

> Could you tell us more detail of process flow?
>
> On Wed, 24 Aug 2022 at 20:52 Mike Oliver <
> mikeol...@open4businessonline.com> wrote:
>
>> Hello, 
>>
>> I want to follow a microservices architecture and have some shared 
>> services I can include in a process flow instead of the 1:1 View:Model 
>>
>> Suggestions?
>>
>> MO
>>
>> -- 
>> 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/fea12690-f86e-4761-9aef-5be7358dea57n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/fea12690-f86e-4761-9aef-5be7358dea57n%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/bb266e45-c506-4e3d-be1d-e7a4363ba9ccn%40googlegroups.com.


Can an app subclass a core django class to channge its behavior

2022-08-24 Thread Mike Oliver
Hello, 

I want to follow a microservices architecture and have some shared services 
I can include in a process flow instead of the 1:1 View:Model 

Suggestions?

MO

-- 
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/fea12690-f86e-4761-9aef-5be7358dea57n%40googlegroups.com.