Re: How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-17 Thread Yavin Aalto Arba
did you try to set "as_attachment=True" ?

-- 
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 post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZWVCysVfPG5iHS_Mr9XgASV_JCPnfj74Yu3edLQ96RNow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-17 Thread Yavin Aalto Arba
will work with window.location=  


On Saturday, November 17, 2018 at 5:55:18 PM UTC+2, Joel wrote:
>
> Yes. But it's not usable when we're using JavaScript to fetch the url.
>
> On Sat, 17 Nov, 2018, 9:20 PM Jason  
> wrote:
>
>> oh, I didn't know that was a thing.  TIL.
>>
>>
>> https://docs.djangoproject.com/en/2.1/ref/request-response/#django.http.FileResponse
>>
>> note the bit about as_attachment setting content disposition
>>
>> -- 
>> 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 post to this group, send email to django...@googlegroups.com 
>> .
>> 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/a950f7f3-2e7e-490d-b271-3125829a9376%40googlegroups.com
>>  
>> 
>> .
>> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/8e08441c-3efd-4fe8-837d-26612ab0d288%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Upload Image Field? ASAP PLS

2018-11-18 Thread Yavin Aalto Arba
Assuming this is just a general question about the subject:

Django Models has an imagefield option:
https://docs.djangoproject.com/en/2.1/ref/models/fields/#django.db.models.ImageField

The image has a .url attribute which you can use for displaying (or you can
use the % static % method). cf. "For example, if your ImageField

is
called mug_shot, you can get the absolute path to your image in a template
with {{ object.mug_shot.url}}."

These attributes shouldn't change in the event that the server manipulates
the image.

the .name attribute will give you the full on-disk path, which you can use
for whichever manipulations you need.



On Sun, 18 Nov 2018 at 04:33, Shashank Singh 
wrote:

> Why not doing it? Where are you stuck?
>
> On Sun, 18 Nov, 2018, 8:02 AM Richard Vo 
>> Need to upload an image, manipulate the image through Python Pillow, then
>> display it.
>>
>> Whatever additional information I need to provide, please let me know.
>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> 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/42fd7a1a-df2f-4ded-807e-413587beaefc%40googlegroups.com
>> 
>> .
>> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> 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/CAD-d1sZiOfx-pKxvQO_CkmTT_PhsVH3EBuZ3usJL_j4K7S1Adw%40mail.gmail.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZXhsqPH9Umzk6CgLF4JD559-TkgFU5vnHN0Tc3PfRnmiA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Send E-mail to User When Account is Activated though Django Admin Application

2018-11-20 Thread Yavin Aalto Arba
I would also recommend checking out using Signals instead of directly from
the view:
https://docs.djangoproject.com/en/2.1/topics/signals/

You can then write a a function that will send an email based on the event.
The sending email documentation is superb:
https://docs.djangoproject.com/en/2.1/topics/email/

On Tue, 20 Nov 2018 at 00:08,  wrote:

> I've done this recently by importing smtplib into my views.py file, and
> made executing a mail send a result of a view.
>
> I didn't realize at the time, but there is Django specific tools for this
> as well.
>
> https://docs.djangoproject.com/en/2.1/topics/email/
>
> On Monday, November 19, 2018 at 2:44:39 PM UTC-6, Asad Habib wrote:
>>
>> Is there a way to send an e-mail to a user when their account is
>> activated through the Django admin application? I can do it independently
>> of the Django admin application but I want the admin to be signed in before
>> they activate a user. Is there a way to achieve this without customizing
>> the Django admin application code? Thanks in advance.
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> 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/ae93581b-a0f9-4eda-91bc-4ec765adcc75%40googlegroups.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZXpkKvOxcVGYxW%3D3aJf%3DacLe9UM8zXGXvtYRV%3DFYmrvHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Approach to implement a Rest call functionality

2018-11-20 Thread Yavin Aalto Arba
Hi Prateek,

I think your best option is using javascript on the front end - leveraging
an ajax post call.

On Tue, 20 Nov 2018 at 13:24, prateek gupta  wrote:

> Hi All,
>
> I have an admin panel built on Django 2.0.6, MySql 5.7 and Python 3.6.
>
> In this panel I have a field 'PIN' described in models.py like below-
> class MerchantStores(models.Model):
> store_id = models.AutoField(primary_key=True)
> pin = models.CharField(unique=True, max_length=45, blank=True,
> null=True)
>
> Currently admin has to fill manually this Pin.
>
> Now, I have to change this PIN text box to a button and on click of this
> button a post request will be sent to an api.
> This button will be enabled once admin will edit the form (since Pin
> generation required store id and a store id will be generated only after
> first creating a new store)
>
> The end point of this api will contain the store_id at the end and will
> have some required input parameters like api id etc.
>
> Since this api itself saves the new Pin in database , so I don't need to
> save this field myself. I just need to show a button and on click this
> button make a call to api.
>
> So for this requirement I am going to use Django Rest Framework but before
> that I need your suggestion to implement it with a better way.
> Please suggest me how can I make a button field instead of text,then  how
> can I append the store_id to the end point and post my request to the api
> successfully?
>
> Thanks,
> Prateek Gupta
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> 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/16480a91-3284-44e7-8e6f-7492b4fb8c73%40googlegroups.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZVeBUEKkbgv9VDjA0ZSPJHR%2BtZ%2BNXCNWT2d_XRKVzUG3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Approach to implement a Rest call functionality

2018-11-20 Thread Yavin Aalto Arba
Not sure if we're a bit confused on the use case here. REST framework is a
server side platform which can help you implement apis fast, it's a good
idea to use if you don't have an endpoint and want fast CRUD
implementation. As for having a button on the client side - you can use
HTML forms or ajax etc. I think JS\Ajax is the way to go since you can
extract stuff from the document with greater ease and send it away to an
endpoint.

On Tue, 20 Nov 2018 at 14:09, prateek gupta  wrote:

> Thanks @Yavin for your suggestion.
> I thought I will have to use Django Rest Framework for this functionality,
> never thought that from front end I can do that :)
>
> On Tuesday, November 20, 2018 at 5:17:35 PM UTC+5:30, Yavin Aalto Arba
> wrote:
>>
>> Hi Prateek,
>>
>> I think your best option is using javascript on the front end -
>> leveraging an ajax post call.
>>
>> On Tue, 20 Nov 2018 at 13:24, prateek gupta  wrote:
>>
>>> Hi All,
>>>
>>> I have an admin panel built on Django 2.0.6, MySql 5.7 and Python 3.6.
>>>
>>> In this panel I have a field 'PIN' described in models.py like below-
>>> class MerchantStores(models.Model):
>>> store_id = models.AutoField(primary_key=True)
>>> pin = models.CharField(unique=True, max_length=45, blank=True,
>>> null=True)
>>>
>>> Currently admin has to fill manually this Pin.
>>>
>>> Now, I have to change this PIN text box to a button and on click of this
>>> button a post request will be sent to an api.
>>> This button will be enabled once admin will edit the form (since Pin
>>> generation required store id and a store id will be generated only after
>>> first creating a new store)
>>>
>>> The end point of this api will contain the store_id at the end and will
>>> have some required input parameters like api id etc.
>>>
>>> Since this api itself saves the new Pin in database , so I don't need to
>>> save this field myself. I just need to show a button and on click this
>>> button make a call to api.
>>>
>>> So for this requirement I am going to use Django Rest Framework but
>>> before that I need your suggestion to implement it with a better way.
>>> Please suggest me how can I make a button field instead of text,then
>>> how can I append the store_id to the end point and post my request to the
>>> api successfully?
>>>
>>> Thanks,
>>> Prateek Gupta
>>>
>>> --
>>> 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 post to this group, send email to django...@googlegroups.com.
>>> 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/16480a91-3284-44e7-8e6f-7492b4fb8c73%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/16480a91-3284-44e7-8e6f-7492b4fb8c73%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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> 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/e9b96409-90c8-41e6-9da1-d3645e92a9ad%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e9b96409-90c8-41e6-9da1-d3645e92a9ad%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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZX2dW7UFhQ7VSOV4n%2BqRcdQ%3DPyd6mCgs_66YVdT2UqN6Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to correct my signals call?

2018-11-21 Thread Yavin Aalto Arba
Can you show us the view where the save() is invoked?

On Wed, 21 Nov 2018 at 10:57, prateek gupta  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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> 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
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZVc4Qr4AS3X_7LL3XGiUL4dhr%3DE7sERFOYypn_E4Ws01g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to correct my signals call?

2018-11-21 Thread Yavin Aalto Arba
if created is true it means that the signal is being sent AFTER the
instance was saved(I am assuming this is a new object and not an update!)

weird.

...what happens when you manually do an MerchantStores.objects.create(...)
call with all the mandatory details?

On Wed, 21 Nov 2018 at 12:33, prateek gupta  wrote:

> I just printed the value of created as
>
> kwargs.get("created")
>
>
> And it''s vaulue is True.
>
> On Wednesday, November 21, 2018 at 3:19:56 PM UTC+5:30, Yavin Aalto Arba
> wrote:
>>
>> Something doesn't add up. Can you check the ["created"] keyword? What
>> does it say?
>>
>> On Wed, 21 Nov 2018 at 11:26, prateek gupta  wrote:
>>
>>> @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  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

Re: How to correct my signals call?

2018-11-21 Thread Yavin Aalto Arba
Saurabh Agrawal, I am not sure either. That's why I wanted to check if
manually the API results are the same. The created keyword returns true so
it HAS to have been run after save().

On Wed, 21 Nov 2018 at 15:37, Saurabh Agrawal 
wrote:

> I am sorry, maybe I am understanding wrong, but isn't log as expected?
>
> Since the signal is run synchronously within the Django request, "POST
> /adminapp/merchantstores/add/" gets logged, only after the signal has
> finished running.
>
> On Wed, Nov 21, 2018 at 6:55 PM Yavin Aalto Arba 
> wrote:
>
>> if created is true it means that the signal is being sent AFTER the
>> instance was saved(I am assuming this is a new object and not an update!)
>>
>> weird.
>>
>> ...what happens when you manually do
>> an MerchantStores.objects.create(...) call with all the mandatory details?
>>
>> On Wed, 21 Nov 2018 at 12:33, prateek gupta  wrote:
>>
>>> I just printed the value of created as
>>>
>>> kwargs.get("created")
>>>
>>>
>>> And it''s vaulue is True.
>>>
>>> On Wednesday, November 21, 2018 at 3:19:56 PM UTC+5:30, Yavin Aalto Arba
>>> wrote:
>>>>
>>>> Something doesn't add up. Can you check the ["created"] keyword? What
>>>> does it say?
>>>>
>>>> On Wed, 21 Nov 2018 at 11:26, prateek gupta  wrote:
>>>>
>>>>> @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 
>>>>>> 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-
>>

Re: Using Django Channels to subscribe to a Redis channel

2018-11-21 Thread Yavin Aalto Arba
try with  self.channel_layer.group_send ?

On Wed, 21 Nov 2018 at 19:44, Nasir Sh  wrote:

> Thanks Andrew this helps me as well. There is a missing piece I don't
> understand yet. In my management command, then I probably will have to use 
> `async_to_sync(channel_layer.group_send)`
> to send the message to consumers (right?). The only problem is that
> whenever I use async_to_sync it creates a new connection to redis every
> single time. I now use channels_redis v2.3.1 and in this version I don't
> get excessive connections but still it opens a new connection on every
> send. I was wondering if that is intentional or not in a sync context and
> if so, how can it be solved.
>
> Thanks again for your great work
>
> On Wednesday, February 22, 2017 at 7:55:33 PM UTC+1, Andrew Godwin wrote:
>>
>> Hi Jochen,
>>
>> Your problem is that if you want to listen to the pubsub channel you will
>> need a dedicated process to do so, as you can't just poll something like
>> that. Given that restriction, you're going to have to write something like
>> a management command that opens a connection to Redis and listens for
>> messages, and then whenever it gets one, sends the message onto a channel
>> in the Django channel system.
>>
>> You can send to channels from anywhere, so it's just a basic listener
>> with one line of channel send added. You're likely to want some sort of
>> logic on these messages, I suspect, so I would send onto a single custom
>> channel and then, now your messages are in the evented channel system, you
>> can then write a consumer for that channel and tie it into the routing and
>> handle any distribution/storage there.
>>
>> This keeps the body of your logic inside the Django consumer code, and
>> the management command nice and simple - it just needs to send onto a
>> custom channel and not worry about what to do with that data, you can hook
>> that up later. If you have fields in the message you split out into
>> different dictionary keys, you can even use the Channels routing options on
>> those fields - so, for example, you could route everything with a certain
>> task name to one consumer, and everything else to a catch-all consumer.
>>
>> Andrew
>>
>> On Wed, Feb 22, 2017 at 6:55 AM, Jochen Breuer  wrote:
>>
>>> Hi!
>>>
>>> I'm not entirely sure where to start and I hope you can help me. I'm
>>> using SaltStack to execute tasks on minions. The results of those jobs
>>> (that's the term used in Salt) are then published to a job cache. In this
>>> case its a Redis server (Redis Pubsub). Now I would like to subscribe to a
>>> specific Redis channel, where the job results are published, with my Django
>>> (Channels) application. Every time a job result is pushed, I'd also like to
>>> push a message to a channel in Django.
>>>
>>> Where to begin? Do I need to write a new protocol server or just a
>>> custom channel? Even after reading the docs I'm still lacking overview.
>>> Perhaps someone can push me into the right direction. Thanks!
>>>
>>> Jochen
>>>
>>> --
>>> 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 post to this group, send email to django...@googlegroups.com.
>>> 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/c933a5b5-7b72-4d7d-985a-a311c0f16b26%40googlegroups.com
>>> 
>>> .
>>> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> 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/800a3278-ba4b-402d-b8ee-341b999879ba%40googlegroups.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZVtt3kw9g-t2_D44aVvjRtBebbUTDbCdnKSD

Re: please i need assistance with mine css file .Mine base.html file failed to load my style.css.

2018-11-21 Thread Yavin Aalto Arba
It might help to create a link to the static file and then check the error
upon reaching the url. I also recommend using the django debugging tool
bar!

Otherwise,  it could really help if u were to share the location of the
file in the project as well as the static url and other static related
settings from settings.py

On Wed, Nov 21, 2018, 5:23 PM Babatunde Akinyanmi  Hi.
>
> You haven't given us any useful information for assisting you. You will
> get more replies if you say what you have done, show what your settings
> look like, tell if your are using the development server, stuff like that.
>
> Welcome to the django community
>
> On Wed, 21 Nov 2018, 16:06 Obodoma Uzondu Vincent, 
> wrote:
>
>> base.html file
>>
>> https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css";
>> integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
>> crossorigin="anonymous">
>> https://code.jquery.com/jquery-3.3.1.slim.min.js";
>> integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
>> crossorigin="anonymous">
>> https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js";
>> integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
>> crossorigin="anonymous">
>> https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js";
>> integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
>> crossorigin="anonymous">
>> {% load static %}
>> 
>> 
>>
>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> 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/CACsKspnJ1iQMBnBn%2BKovaFBxzVFKA1GyEpKERFhcxvWSFTamEQ%40mail.gmail.com
>> 
>> .
>> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> 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/CA%2BWjgXNy70-%2BquRPTLpAwnY9Rnc4Cm-n8NEuwMYLgDhzX%3D5%3DjA%40mail.gmail.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZWsNKgzYc8hcOCguT4vpnrmsbgnt7JwNdRG3f9PSQv1qA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: python manage.py runserver

2018-11-21 Thread Yavin Aalto Arba
Mohamed, if you have some time I can do a webex session with you to check
it out.

On Thu, Nov 22, 2018, 5:24 AM Alfredo Sumague  did you run it inside your project directory?
>
> On Wed, Nov 21, 2018 at 11:47 AM Mohamed Hashi 
> wrote:
>
>> i install wrap
>> but till now python manage.py runserver isnt running with me
>> guys any help plz
>>
>> ‫في الأربعاء، 21 نوفمبر 2018 في 7:16 م تمت كتابة ما يلي بواسطة ‪Shubham
>> Rewale‬‏ <‪rewale...@gmail.com‬‏>:‬
>>
>>> Also install wrapped if you haven't already
>>>
>>> On Wed, 21 Nov 2018, 7:08 p.m. رهام صادقی >>
 Hi,
 use the following command and see if it works...
 ./manage.py runserver

 ‫‪Ayser shuhaib‬‏ <‪embedded.mana...@gmail.com‬‏> در تاریخ سه‌شنبه ۲۰
 نوامبر ۲۰۱۸ ساعت ۲۲:۳۴ نوشت:‬

> What is the message that you get when you run Python manage.py
> runserver
>
> On Tue, 20 Nov 2018 at 20:58, Mohamed Hashi 
> wrote:
>
>> i wrote pip install virtualenv
>> and installed
>> buy when i do all the steps to start django web
>> and i came for python manage.py runserver isnt work
>> so and help bro
>>
>> ‫في الجمعة، 16 نوفمبر 2018 في 12:53 ص تمت كتابة ما يلي بواسطة
>> ‪Mamadou Harouna Diallo‬‏ <‪dev.haro...@gmail.com‬‏>:‬
>>
>>> Are you active your virtuel env if you are use it ?
>>> Or verify if you are in the folder where manage.py is ?
>>>
>>> Le jeu. 15 nov. 2018 18:14,  a écrit :
>>>
 python manage.py runserver isnt running with me








































































 --
 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 post to this group, send email to django-users@googlegroups.com.
 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/430cec4b-0301-44af-9654-a03eafec4fd5%40googlegroups.com
 
 .
 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 django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> 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/CAO73PDqCX0Tghqz0nY-3p3wfZogRnt06HLN4AoE5zosp6efLQw%40mail.gmail.com
>>> 
>>> .
>>> 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 django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> 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/CAOiYw3tYEJy%3Dz9Yg0FG6R7%2B5VAcYAe9PcV_zS1YqPss%2BnxMqeA%40mail.gmail.com
>> 
>> .
>> 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 django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit 

Re: difference between class based view and function based view

2018-11-22 Thread Yavin Aalto Arba
I have to +1 Carstens answer.

 In short, I too find CB views to be too "magical".

=)

On Thu, 22 Nov 2018 at 11:53, Carsten Fuchs  wrote:

> Hi Andrew,
>
> many thanks for your clear and detailed explanation!
>
> Having used Django for several years, FVs are still my favorite approach
> over CBVs and GCBVs. In the past, I made several starts with CBVs, but
> never found or understood why CBVs and GCBVs seem to be in many people's
> center of attention.
>
> FVs are not only the most simple of the three, but they also have the
> virtue of emphasizing the basic generic HTML web functionality and the
> way how forms work: The three logical paths that form processing can
> take are clearly shown in e.g. this (modified) example from
> https://django-book.readthedocs.io/en/latest/chapter07.html
>
> def contact(request):
>  if request.method == 'POST':
>  form = ContactForm(request.POST)
>  if form.is_valid():
>  # success, now use form.cleaned_data
>  return HttpResponseRedirect('/contact/thanks/')
>  else:
>  form = ContactForm()
>
>  # We get here both for GET requests and POST requests
>  # with invalid forms.
>  return render(request, 'contact_form.html', {'form': form})
>
> When I was new to Django (and in fact new to serious web development),
> understanding this concept, as step by step explained in the above
> mentioned chapter, was one of the key insights for me.
>
> CBV and GCBV obscure this imho fundamental concept. Personally, I've
> never found the CBV's help with DRY outweigh the clarity of FVs. With
> all the attention and efforts that are spent on making getting started
> with Django easier for beginners, I was really surprised when even the
> official Django tutorials were changed from FVs to CBVs.
>
> I write this email to thank you for your explanation, but also to add
> the above thoughts, which I have long been pondering but never found a
> place to write down.  ;-)
>
> Best regards,
> Carsten
>
>
> Am 21.11.18 um 21:39 schrieb Andrew Pinkham:
> > Django developers talk about three kinds of views:
> >
> >   - function views (FV)
> >   - class-based views (CBV)
> >   - generic class-based views (GCBV)
> >
> > People do not make always make the difference between CBV and GCBV,
> which is unfortunate, as they serve different purposes (naming things is
> hard). When Andréas states earlier in this thread that "(CBV) use a lot of
> defaults for populating your templates, forms and views" that is not 100%
> precise. He means GCBV---which provide default (generic) behavior---not CBV.
> >
> > Let's break it down. Below is an example of a FV.
> >
> >  from django.http import HttpResponse
> >  from django.views.decorators.http import (
> >  require_http_methods
> >  )
> >
> >  # below is equivalent to require_safe decorator
> >  @require_http_methods(["GET", "HEAD"])
> >  def hello_world(request):
> >  """Demonstrate HTTP Request/Response"""
> >  return HttpResponse("Hello World")
> >
> > Below is an example of an equivalent CBV.
> >
> >  from django.http import HttpResponse
> >  from django.views import View
> >
> > class HelloWorld(View):
> >   """Demonstrate HTTP Request/Response"""
> >
> >  def get(self, request):
> >  """Handle GET HTTP method"""
> >  return HttpResponse("Hello World")
> >
> > Formally, a CBV is any class that inherits from View. The only
> difference between the two views above is that the View class being
> inherited will give you automatic handling of HTTP OPTIONS.
> >
> > Stated otherwise: FV and CBV are *equivalent* with the exception of
> automatic OPTIONS handling in CBV.
> >
> > GCBV are simply CBV that have been given behavior. For example, instead
> of programming a view that shows a template with model data, you can
> instead inherit a DetailView, and customize it by setting class variables
> and by overriding methods. For more about that, I recommend looking at
> https://ccbv.co.uk .
> >
> > So, when should you use a FV, CBV, or GCBV?
> >
> > If you are building a view that a GCBV provides behavior for, save
> yourself time and use it! It's easy to add or slightly modify GCBV
> behavior, but difficult to remove behavior. The moment you're thinking
> about removing something a GCBV does, stick to a function or CBV.
> >
> > So then, for choosing between FV or CBV: Do you need to handle multiple
> HTTP methods? Is there shared behavior between how the resource is handled
> by those HTTP methods? If yes, a CBV can help organize that logic and avoid
> duplicate code.
> >
> > However, if you have a simple view (typically only one or two HTTP
> methods must be handled), then a FV will serve you fine (remember the view
> decorators!).
> >
> > If you're not sure, start with a FV, and then switch to a CBV or GCBV if
> appropriate (as complexity goes up or when you realize you can use a GCBV).
> >
> > 

Re: email

2018-11-22 Thread Yavin Aalto Arba
https://docs.python.org/3/library/sched.html ?

On Thu, 22 Nov 2018 at 11:29, Tushar Nadkar 
wrote:

> i have email id of multiple user , so how can i send mail after 3 days
> when he click a button .or checkout button in django
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> 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/CAAHYEvMrV2x2TOwL1NmDrJAxpxVSFU%2BkiyeaWPdYhF09SfzPTg%40mail.gmail.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZXVnHnatnY%3DhKvHLLkwY9oJZXTBxxhBSD9QXiC%2BZE%2Bqmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Django Channels to subscribe to a Redis channel

2018-11-22 Thread Yavin Aalto Arba
You need to set up the consumer to perform this task.

cf. https://github.com/justdjango/justchat/blob/master/src/chat/consumers.py

this corresponds to the following video tutorial which might be useful to
you:
https://www.youtube.com/watch?v=Wv5jlmJs2sU

On Thu, 22 Nov 2018 at 15:34, Nasir Sh  wrote:

> Thanks Yyavin, the problem is that in my management command I don't have
> access to `self` to send it. Is it possible to get access to a consumer
> from outside or how should my data producer relay the messages to channel
> in an async way?
>
> On Wednesday, November 21, 2018 at 8:47:07 PM UTC+1, Yavin Aalto Arba
> wrote:
>>
>> try with  self.channel_layer.group_send ?
>>
>> On Wed, 21 Nov 2018 at 19:44, Nasir Sh  wrote:
>>
>>> Thanks Andrew this helps me as well. There is a missing piece I don't
>>> understand yet. In my management command, then I probably will have to use 
>>> `async_to_sync(channel_layer.group_send)`
>>> to send the message to consumers (right?). The only problem is that
>>> whenever I use async_to_sync it creates a new connection to redis every
>>> single time. I now use channels_redis v2.3.1 and in this version I don't
>>> get excessive connections but still it opens a new connection on every
>>> send. I was wondering if that is intentional or not in a sync context and
>>> if so, how can it be solved.
>>>
>>> Thanks again for your great work
>>>
>>> On Wednesday, February 22, 2017 at 7:55:33 PM UTC+1, Andrew Godwin wrote:
>>>>
>>>> Hi Jochen,
>>>>
>>>> Your problem is that if you want to listen to the pubsub channel you
>>>> will need a dedicated process to do so, as you can't just poll something
>>>> like that. Given that restriction, you're going to have to write something
>>>> like a management command that opens a connection to Redis and listens for
>>>> messages, and then whenever it gets one, sends the message onto a channel
>>>> in the Django channel system.
>>>>
>>>> You can send to channels from anywhere, so it's just a basic listener
>>>> with one line of channel send added. You're likely to want some sort of
>>>> logic on these messages, I suspect, so I would send onto a single custom
>>>> channel and then, now your messages are in the evented channel system, you
>>>> can then write a consumer for that channel and tie it into the routing and
>>>> handle any distribution/storage there.
>>>>
>>>> This keeps the body of your logic inside the Django consumer code, and
>>>> the management command nice and simple - it just needs to send onto a
>>>> custom channel and not worry about what to do with that data, you can hook
>>>> that up later. If you have fields in the message you split out into
>>>> different dictionary keys, you can even use the Channels routing options on
>>>> those fields - so, for example, you could route everything with a certain
>>>> task name to one consumer, and everything else to a catch-all consumer.
>>>>
>>>> Andrew
>>>>
>>>> On Wed, Feb 22, 2017 at 6:55 AM, Jochen Breuer 
>>>> wrote:
>>>>
>>>>> Hi!
>>>>>
>>>>> I'm not entirely sure where to start and I hope you can help me. I'm
>>>>> using SaltStack to execute tasks on minions. The results of those jobs
>>>>> (that's the term used in Salt) are then published to a job cache. In this
>>>>> case its a Redis server (Redis Pubsub). Now I would like to subscribe to a
>>>>> specific Redis channel, where the job results are published, with my 
>>>>> Django
>>>>> (Channels) application. Every time a job result is pushed, I'd also like 
>>>>> to
>>>>> push a message to a channel in Django.
>>>>>
>>>>> Where to begin? Do I need to write a new protocol server or just a
>>>>> custom channel? Even after reading the docs I'm still lacking overview.
>>>>> Perhaps someone can push me into the right direction. Thanks!
>>>>>
>>>>> Jochen
>>>>>
>>>>> --
>>>>> 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.
>>

Re: URL path not working with Django ver 2.1.2

2018-11-22 Thread Yavin Aalto Arba
Path is not using regular expressions. Use empty quotes and it should work.

On Fri, Nov 23, 2018, 5:28 AM Ben Hamlitsch  This is the message I get when I run python manage.py runserver
>
> [image: Screen Shot 2018-11-22 at 7.18.58 PM.png]
>
>
> This is my setup in Atom
>
>
> [image: Screen Shot 2018-11-22 at 7.22.10 PM.png]
>
>
> ANY help you can provide much appreciated.
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> 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/11324094-eea3-488c-b8dd-9e0cc1d38262%40googlegroups.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZUdOsZRJwJwikmbMN-EzTuY9H%2BOf61XpWGXquLgpX_L%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: need help on form view

2018-11-23 Thread Yavin Aalto Arba
I think the problematic part is " create_user = UserCreationForm(request.
POST or None)"

Most FBV for forms start with the "if request.method == 'POST" and then
continue to fill the form. You can set the "None" after the if statement
instead of before everything else.

I am not sure that the or NONE syntax is working properly in your usage for
this. Could be wrong. I suggest to try using the boilerplate way.

On Fri, 23 Nov 2018 at 11:21, Tosin Ayoola  wrote:

> Good day Guys,
> working on a 3 step form but the issue now is that at the 2nd step the
> form instead of redirecting the user to the final step, it instead
> redirects back to the 1st step. below is my view, url code
> #Views
> def add_user(request):
> create_user = UserCreationForm(request.POST or None)
> if request.method == 'POST' and create_user.is_valid():
> create_user.save()
> return redirect(reverse('schoolprofile1'))
>
> return render( request, 'create_user_form.html',
> {'create_user': create_user,
> })
>
>
>
> def schoolprofile1(request):
> school_info = SchoolsForm(request.POST or None )
> if request.method == 'POST' and school_info.is_valid():
> request.session['school_data'] = school_info.cleaned_data
> return redirect(reverse('schoolprofile2'))
>
> return render(request, 'schoolprofile1.html',{
> 'school_info': school_info,
> })
>
>
> def schoolprofile2(request):
> school_info_two = SchoolDataForm(request.POST)
> if request.method == 'POST' and school_data.is_valid():
> complete_school_data_ = {
> **request.session['school_data'],
> **school_info_two.cleaned_data
> }
> Schools.object.create(**complete_school_data)
>
> return redirect('schoolDetail')
>
> return render(request, 'schoolprofile2.html',{
> 'school_data':school_info_two,
> })
>
> #URL
>
> urlpatterns = [
> path('', views.index, name = 'index'),
> path('schoolprofile/step-two', views.schoolprofile2, name='schoolprofile2'
> ),
> path('schoolprofile/step-one', views.schoolprofile1, name = '
> schoolprofile1'),
> path('schoolprofile/add-user', views.add_user, name= 'add_user'),
> path('schoolprofile', views.add_school, name='add_school'),
> #path(r'ProfileYourSchool', add_School.as_view([profileForm, SchoolsForm,
> schoolDataForm]), name = 'add_Schools'),
> path(r'ContactUs', views.Contact, name = 'Contact'),
> ]
>
>
> thanks
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> 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/CAHLKn73kTShkC7NsertLBbvrMnDp%3DJNQ0w2_iN41s-fVDiyRHw%40mail.gmail.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZVDX%2BdzyJ4fJ2L7sKvDsDaOWJYKjUfRGTsROtGyxcEBwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Website is running in Django and also clients want to make the Mobile APP.

2018-11-23 Thread Yavin Aalto Arba
There's a django plugin to quickly recognize if the page is loaded from a
mobile device and serve different templates accordingly:
*https://djangopackages.org/packages/p/django-mobile/
*

HOWEVER, I think a more simple and effective approach would be to work with
a one-stop-shop front end reactive design platform: Mobile-JQuery, React,
etc. which work well on all page resolutions.



On Fri, 23 Nov 2018 at 10:21, Jani Tiainen  wrote:

> Hi,
>
> You can access Django site for example via RESTful API.
>
> On Fri, Nov 23, 2018 at 9:52 AM Pravin Yadav  wrote:
>
>> Hello Everyone,
>>
>> Good Morning,
>>
>> I have created the website in Django + Python3. Website is running.
>> But I want to make the Mobile App. Can anyone guide me how will i work.
>>
>>
>>
>> Thanks & Regards,
>> Pravin Kr Yadav
>>
>> --
>> 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 post to this group, send email to django-users@googlegroups.com.
>> 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/CAEr6%3DdyscxarOk4zNbERTaANf%2BAbnMHonFCYMau3dJH0nBMV4A%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient before...
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> 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/CAHn91odZE%2B_wWJBy8aviRgzYdKP1VTxvjkd05XTx%2Bon4VQGmnw%40mail.gmail.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZXh7Zva8_q3JQGYN0C4krgatDzhHwH4qt%2BViH_LuACYrQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to autosave Foreignkey value inside my second Model with the id of my first model object.??

2018-11-25 Thread Yavin Aalto Arba
The whole point of a foreign key is that it's external\independent the
related model - and you are going against that by giving the user the
ability to enter it willy-nilly in one form. If you want to have a 2 key
combo as primary key you can use unique_together without the second model
as a FK   (
https://docs.djangoproject.com/en/2.1/ref/models/options/#unique-together)

If you really insist on this design...You could make two forms (one for the
appname and one for the other model without the appname) and set the saving
of the second form with a save(commit=False). then, set the FK according to
the first saved form input. It's pretty ugly imho but it can be done, cf.
https://stackoverflow.com/questions/569468/django-multiple-models-in-one-template-using-forms/575133#575133

On Sun, 25 Nov 2018 at 15:49, Anoop Sharma  wrote:

>
> I have two models . Appname and Adspace ,I have a Foreignkey object
> in second model which connects to my first model. Here is the Code
>
>
> models.py
>
>  class Appname(models.Model):
>   
> name=models.CharField(max_length=150,blank=False,null=False,help_text='Add 
> your new App')
>
>   def __str__(self):
>   return self.name
>
>   def get_absolute_url(self):
>   return reverse("dashapp:space",kwargs={'pk':self.pk})
>
>
> class Adspace(models.Model):
>   ad_space=models.CharField(max_length=150,blank=False,null=False)
>   app=models.ForeignKey('Appname', related_name='appnames',default=None, 
> on_delete=models.CASCADE)
>   PID_TYPE = (
> ('FN','FORMAT_NATIVE'),
> ('FNB','FORMAT_NATIVE_BANNER'),
> ('FI','FORMAT_INTERSTITIAL'),
> ('FB','FORMAT_BANNER'),
> ('FMR','FORMAT_MEDIUM,RECT'),
> ('FRV','FORMAT_REWARDED_VIDEO'),
> )
>  
> format_type=models.CharField(max_length=3,choices=PID_TYPE,default='FN',blank=False,
>  null=False)
>
>  def __str__(self):
>   return self.ad_space
>
>  def get_absolute_url(self):
>   return reverse("dashapp:view")
>
>
>
> modelForm
>
> class AdspaceForm(forms.ModelForm):
> class Meta:
>model=Adspace
>fields=('ad_space',)
>
>
>
> Views.py
>
> class space(LoginRequiredMixin,CreateView):
>
>form_class=forms.AdspaceForm
>model=Adspace
>
>
>
> Now I.m unable to fill my form as it says it app_id cannot be null
> and i'm allowing user to input it. I want that the app which got clicked
>  has its ID in the url (As I'm passing it through there).
> What should i do that it gets autosave with the same id number by itself
>  that is being passed in the url.
>
>
>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> 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/4a23635c-1d6c-4dba-b011-778c1548f938%40googlegroups.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZU%3DkLUBGPrZQQ9hoXDemM1RJtB8aorj%2B_GhXhDNwEiaLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom attributes in django forms

2018-11-26 Thread Yavin Aalto Arba
Hi Gordon,

Try starting with the documentation here and if u have any questions please
let us know:

https://docs.djangoproject.com/en/2.1/ref/forms/widgets/

On Sun, Nov 25, 2018, 11:09 PM gordon nchy  hello everyone
> i'm facing a challenge on how to add custom attributes to django login
> form. i used the LoginView from django.contrib.auth.views to generate a
> login form, but i really need help on how to add custom attributes maybe
> like using widgets but i dont know how to do it..i'll appreciate any help
> from you guys!!
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> 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/1b463fa5-ab80-4182-8022-5fe33b695444%40googlegroups.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZUwP2q-fEXKWQ8mZa6uEZH%2BzExExWiHuDO3%3DGko9K2SyA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to fix this problem using 2.1.3 version

2018-11-26 Thread Yavin Aalto Arba
did you import settings?

On Mon, 26 Nov 2018 at 15:34, Abba Haruna  wrote:

> if settings.DEBUG:
> # urlpatterns += patterns('',
> # ('media/(?P.*)',
> # 'django.views.static.serve',
> # {'document_root': settings.MEDIA_ROOT}))
>
>
>
> this is the result
>
>  File "C:\Users\Abba\Desktop\rest_picker\restaurants\urls.py", line 22
> if settings.DEBUG:
>  ^
> SyntaxError: invalid syntax
>
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> 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/9f08ad47-6d28-44ef-ba8c-7bfbb9aca8be%40googlegroups.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZX%3DkfFRPBe_edkvQg1vD3F89FUrHfQ-JOKpR793zHS4qA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to fix this problem using 2.1.3 version

2018-11-26 Thread Yavin Aalto Arba
It's kinda all over the place.

1. conventions:
urlpatterns is a list not a tuple
2.
'restaurants.views',  without include? what's this for?

3. You did not close the parenthesis correctly in the second item, here's
how its supposed to be written:

path('',ListView.as_view(model=Food,
template_name='restaurants/index.html',  name='index'))


4.you are using path and instead of path_re



On Mon, 26 Nov 2018 at 16:03, Abba Haruna  wrote:

> even if i close it is not working
>
> On Mon, Nov 26, 2018 at 5:54 AM Michal Petrucha <
> michal.petru...@konk.org> wrote:
>
>> On Mon, Nov 26, 2018 at 02:48:25PM -0800, Abba Haruna wrote:
>> > # from django.conf.urls import patterns, url
>> > from django.conf.urls.static import static
>> > from django.views.generic import ListView
>> > from restaurants.models import Food
>> > from django.conf import settings
>> >
>> > urlpatterns = ('restaurants.views',
>> > path('',ListView.as_view(model=Food,
>> template_name='restaurants/index.html',
>> > name='index'),
>>
>> You've got an unclosed parenthesis on the line above.
>>
>> > path('food/(?P<food_id>\d+)/',
>> > 'choose_town', name='choose_town'),
>> > path('food/(?P<food_id>\d+)/town/(?P<town_id>\d+)/',
>> > 'choose_restaurant',
>> > name='choose_restaurant'),
>> > path('rest/(?P<rest_id>\d+)/',
>> > 'restaurant',
>> > name='restaurant'),
>> > path('(?P<rest_id>\d+)/vote/',
>> > 'vote',
>> > name='vote'),
>> > )
>> >
>> >
>> > if settings.DEBUG:
>> > urlpatterns += patterns('',
>> > ('media/(?P.*)',
>> > 'django.views.static.serve',
>> > {'document_root': settings.MEDIA_ROOT}))
>> >
>> > On Mon, Nov 26, 2018 at 5:47 AM Yavin Aalto Arba 
>> > wrote:
>> >
>> > > did you import settings?
>> > >
>> > > On Mon, 26 Nov 2018 at 15:34, Abba Haruna 
>> wrote:
>> > >
>> > >> if settings.DEBUG:
>> > >> # urlpatterns += patterns('',
>> > >> # ('media/(?P.*)',
>> > >> # 'django.views.static.serve',
>> > >> # {'document_root': settings.MEDIA_ROOT}))
>> > >>
>> > >>
>> > >>
>> > >> this is the result
>> > >>
>> > >>  File "C:\Users\Abba\Desktop\rest_picker\restaurants\urls.py", line
>> 22
>> > >> if settings.DEBUG:
>> > >>  ^
>> > >> SyntaxError: invalid syntax
>> > >>
>> > >>
>> > >> --
>> > >> 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 post to this group, send email to django-users@googlegroups.com.
>> > >> 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/9f08ad47-6d28-44ef-ba8c-7bfbb9aca8be%40googlegroups.com
>> > >> <
>> https://groups.google.com/d/msgid/django-users/9f08ad47-6d28-44ef-ba8c-7bfbb9aca8be%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 a topic in the
>> > > Google Groups "Django users" group.
>> > > To unsubscribe from this topic, visit
>> > >
>> https://groups.google.com/d/topic/django-users/syLm4GpiFqg/unsubscribe.
>> > > To unsubscribe from this group and all its topics, send an email to
>> > > django-users+unsubscr...@googlegroups.com.
>> > > To post to this group, send email to django-users@googlegroups.com.
>> > > Visit this group at https://groups.google.com/group/django-users.
>> > > To view this discussion on the web visit
>> > >
&g

Re: [ask] Django video streaming server

2018-12-15 Thread Yavin Aalto Arba
https://github.com/andrewebdev/django-video

there are plenty of other good plugin out there. Why build from scratch?
Other peoples peer-reviewed plugin are most likely better than whatever you
can muster in a few days\weeks :)



On Sun, 16 Dec 2018 at 04:41, Riska Kurnianto 
wrote:

> Hello all, is there any rigit method to build video streming server with
> django??
> I tried google but not find something interesting
>
> --
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> 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/CAG7yD2LP%3DXGqXbzmkHcMiSV2pRW7fHoP-4BOV6SxGB3jG-9__Q%40mail.gmail.com
> 
> .
> 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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CA%2B%2Be-ZWwsqeO-04srXgS7nFR7UD93oiP2D_g9KTZD0m5Q56V-A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.