@Yavin Aalto Arba

I am using models.py, admin.py for my view, no any customized forms or view.

[image: screen_3.JPG]

[image: screen_2.JPG]

[image: screen_1.JPG]
PFA screen shot for the same.

On Wednesday, November 21, 2018 at 2:46:41 PM UTC+5:30, Yavin Aalto Arba 
wrote:
>
> Can you show us the view where the save() is invoked?
>
> On Wed, 21 Nov 2018 at 10:57, prateek gupta <[email protected] 
> <javascript:>> wrote:
>
>> Hi All,
>>
>> I have an admin panel built on Django 2.0.6, Mysql 5.7 and Python 3.6.
>>
>> Now I have written following signal code in signals.py-
>> from .models import MerchantStores
>> from django.db.models.signals import post_save
>> from django.dispatch import receiver
>>
>> @receiver(post_save, sender = MerchantStores, weak=False)
>> def ensure_store_id_exists(sender, **kwargs):
>>    print ("check fucntion")
>>    ex = kwargs.get("instance").store_id
>>    print ("store id:",ex)
>>    import requests
>>    URL = "http://example.cloud/rmsservice/resetPin?storeId="+str(ex)
>>    print("url:",URL)
>>    data = {'Content-Type': 'application/json',
>>            'app-id': 'APP_ID',
>>            'secret-key': 'SECRET_KEY',
>>            'aid': 'PG'}
>>
>>    r = requests.post(url=URL, headers=data)
>>    response_text = r.text
>>    print(response_text)
>>
>> And in apps.py I have done following settings-
>>
>> from django.apps import AppConfig
>>
>> class AdminappConfig(AppConfig):
>>     name = 'adminapp'
>>
>>     def ready(self):
>>         import adminapp.signals
>>
>>
>> In above signals I am sending a post request to resetPin api.
>> I need to send the request once form is saved but my signal is posting 
>> request before the save method.
>> I confirmed the above from server logs. Following is the logs I am 
>> getting-
>> [21/Nov/2018 14:18:03] "GET /jsi18n/ HTTP/1.1" 200 3185
>> check fucntion
>> store id: 1533
>> url: http://example/rmsservice/resetPin?storeId=1533
>> {"success":false,"code":"8050","message":"Merchant not 
>> active","response":null}
>> [21/Nov/2018 14:18:29] "POST /adminapp/merchantstores/add/ HTTP/1.1" 302 0
>> [21/Nov/2018 14:18:32] "GET /adminapp/merchantstores/ HTTP/1.1" 200 12659
>> [21/Nov/2018 14:18:34] "GET /jsi18n/ HTTP/1.1" 200 3185
>>
>> As per above log, my signal is invoked before teh save() method but it 
>> should be after the save() method.
>> Can anyone please help my to find out what I am doing wrong here?
>>
>> Thanks,
>> Prateek
>>
>> -- 
>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/9edd586b-604b-4734-ab1d-28f7fda9d527%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/9edd586b-604b-4734-ab1d-28f7fda9d527%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/92aa3ade-9525-4f99-a85f-aef4c57172ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to