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: How to get superuser access to bypass payments page

2022-10-20 Thread Gabriel Araya Garcia
In template you should put an conditional, if it is an any user then show
the real price and if it's a superuser then show zero. And on the back-end
you should ask the same question at the time to save.

gabrielaraya2...@gmail.com

Regards


Gabriel Araya Garcia
GMI - Desarrollo de Sistemas Informáticos




El jue, 20 oct 2022 a las 15:55, Silver Trinity ()
escribió:

> Hello all new developer here,
>
> I am working with existing code base and want to fix an issue in the
> system. Here is the problem:
>
> When a superuser logs into the site and selects a product, he is charged
> and I have to implement a 100% discount to his price so he doesn't have to
> pay. This is inefficient and I want to do it another way.
>
> How can I change this so that a superuser can select a product,  and
> bypass the payment section? Here is some code for reference along with the
> mixins being used:
>
> Code snippets:
> https://pastebin.com/3RTKAi9U
> https://pastebin.com/g6vdX5Uk
>
>
>
>
>
> --
> 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/eea3c99f-e086-4cd8-8874-dfe4e333e276n%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/CAKVvSDAUkUkP6SYpyyFDt60zbhHQ8wdx6HpyVWOpS6uquNNsUQ%40mail.gmail.com.


How to get superuser access to bypass payments page

2022-10-20 Thread Silver Trinity
Hello all new developer here,

I am working with existing code base and want to fix an issue in the 
system. Here is the problem: 

When a superuser logs into the site and selects a product, he is charged 
and I have to implement a 100% discount to his price so he doesn't have to 
pay. This is inefficient and I want to do it another way. 

How can I change this so that a superuser can select a product,  and bypass 
the payment section? Here is some code for reference along with the mixins 
being used:

Code snippets:
https://pastebin.com/3RTKAi9U
https://pastebin.com/g6vdX5Uk





-- 
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/eea3c99f-e086-4cd8-8874-dfe4e333e276n%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: Combining django apps

2022-10-20 Thread Aziz Mek
Hi,

Both are correct and lead to the same thing, however Django documentation 
seems to prefer  *odo.apps.TodoConfig*

I hope that helps

Kind regards
Aziz

On Wednesday, October 19, 2022 at 8:10:05 AM UTC+1 tna...@gmail.com wrote:

> Also, some website says something like
>
> INSTALLED_APPS = [ 'todo.apps.TodoConfig', 
>
>  
>
> You say,
>
> INSTALLED_APPS = [ 'todo', 
> I am confused. Which is proper? And the difference?  
>
>
> 2022年10月19日水曜日 13:49:41 UTC+9 eupaulo...@gmail.com:
>
>> First of all, you need to add all your apps in INSTALED APPS into the 
>> project > setings.py. I have 3 apps, core, members, and home. 
>
>
>> INSTALLED_APPS = [
>>   (..)
>>   'core',
>>   'members',
>>   'home',
>>  ]
>>
>> Secondly, you need to create a route to each app in your project > urls.py
>>
>> urlpatterns = [
>>   path(' ', include('home.urls')),
>>   path('udemy/', include('core.urls')),
>>   path('w3schools/', include('members.urls')),
>>   path('c-panel/', admin.site.urls),
>>  ]
>>
>>
>> After that, each app will be self-independent I  mean with your own 
>> models, templates, statics, etc. 
>>
>> * Of course, you will need to run state collect and migrations commands 
>> on the terminal 
>> ** make sure -->  ROOT_URLCONF = 'YOURPROJECT.urls' <-- project > 
>> setings.py
>>
>> Let me show you an example 
>>
>>
>>
>>
>> Em terça-feira, 18 de outubro de 2022 às 07:01:15 UTC-3, tna...@gmail.com 
>> escreveu:
>>
>>>
>>> mysite/
>>>
>>> manage.py
>>>
>>> config/
>>>
>>> __init__.py
>>>
>>> settings.py
>>>
>>> urls.py
>>>
>>> wsgi.py
>>>
>>> app1/
>>>
>>> app1a/
>>>
>>>   app1b/
>>>
>>> app2/
>>>
>>> app3/
>>>
>>> I would like to know how to combine  apps together just like above.  
>>> Each app itself  works fine when runserver. I followed some websites 
>>> talking about this but I always get some error like ‘app1a' is not a 
>>> registered namespace. I'm not very familiar with combining apps. I hope 
>>> someone can tell me the simplest way to do that.
>>>
>>> Thank you.
>>>
>>

-- 
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/adfb2031-db86-45ab-a58e-6d07ca1b3514n%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.


Django call_command from Admin

2022-10-20 Thread Aziz Mek
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.


Re: Combining django apps

2022-10-20 Thread ASAMOAH EMMANUEL
Register all your apps in the settings.py file and ensure the namespace is
set to the app name in the urls.py in the project directory

On Tue, Oct 18, 2022 at 10:01 AM Jun Tanaka  wrote:

>
> mysite/
>
> manage.py
>
> config/
>
> __init__.py
>
> settings.py
>
> urls.py
>
> wsgi.py
>
> app1/
>
> app1a/
>
> app1b/
>
> app2/
>
> app3/
>
> I would like to know how to combine  apps together just like above.  Each
> app itself  works fine when runserver. I followed some websites talking
> about this but I always get some error like ‘app1a' is not a registered
> namespace. I'm not very familiar with combining apps. I hope someone can
> tell me the simplest way to do that.
>
> Thank you.
>
> --
> 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/f4a91be8-c4a3-4fa1-9a73-bd202f1f6716n%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/CABFHQYwkxYCV-H4g0y3ujdgWY4CgHu0ezivht_V%2BNgkbnErJVA%40mail.gmail.com.