Re: Django to serve JSON: overkill?

2018-10-28 Thread Charley Paulus
Hi Eric,

Yes that helps a lot.
I have data models and related DB.
I’ll go with Django.

Thanks.

Best regards,
Charley

-- 
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/77c35a21-591d-41e5-8bd5-4314a5b0614d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django to serve JSON: overkill?

2018-10-27 Thread Charley Paulus
Hi,

Is it overkill to use Django just to dispatch url requests and to reply with 
JSON (i.e. not using at all the HTML template engine)?

Thanks.

Best regards,
Charley

-- 
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/fac5482d-3d6d-4970-8700-61a710026ba5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trigger actions independently of url request

2018-10-27 Thread Charley Paulus
Hi Joel,

Thanks for sharing your experience. That’s perfect. This way I can make use of 
my Django models in the script called by cron.

Best regards,

Charley Paulus
+1 917 692 2645

> On Oct 26, 2018, at 22:22, Joel  wrote:
> 
> There's nothing that prevents you from doing the necessary imports of your 
> django model and other required modules in a python script, and then have it 
> run by cron. Is there? 
> 
> I've operated python scripts outside of the django application, just to 
> import certain files into the database, which needs to be done only on the 
> server side, infrequently. This seems just like this, except it needs to be 
> done frequently. The linux cron does this very well.
> 
>> On Tue, 23 Oct, 2018, 1:41 AM Charley Paulus,  
>> wrote:
>> Hi Andrew,
>> 
>> Thank you for your answer.
>> 
>> To better clarify my need, here is one use case:
>> 1) I would like my server (where Django is) to ping a remote address (let's 
>> say google.com) every 10 minutes, and put the result (communication ok or 
>> not) in a Django-generated database.
>> 2) Then I will have a Django view that displays some statistics based on 
>> this database records. No worries for this point. My question is strictly on 
>> point 1.
>> 
>> So what I need is my server itself to run code on a regular basis.
>> Can I simply start a thread in manage.py, like here: 
>> https://eldarion.com/blog/2013/02/14/entry-point-hook-django-projects/ ?
>> 
>> It seems that Celery and AWS Lambda are external tools that can remotely 
>> call my Django API.
>> 
>> I hope the example helps.
>> 
>> Thanks again.
>> 
>> Best regards,
>> Charley
>> 
>> 
>>> On Monday, October 22, 2018 at 1:10:52 PM UTC-4, Andrew Pinkham wrote:
>>> On Oct 22, 2018, at 12:08, Charley Paulus  wrote: 
>>> > After reading the Django tutorial, my understanding (I hope I’m wrong) is 
>>> > that the only way to trigger a function of a Django app is when someone 
>>> > on the client side request the url related to that function. 
>>> 
>>> That is correct. A view function/object is only called when a site visitor 
>>> is routed to that callable by the URL configuration. 
>>> 
>>> > But what if I want the server to run a function indenpendently of a url 
>>> > call, for example: 
>>> > - every 10 minutes 
>>> > - when a pre-defined combination of variables become true 
>>> 
>>> I'm not clear on your second condition, but you are probably interested in 
>>> Celery for the first. 
>>> 
>>> http://www.celeryproject.org/ 
>>> 
>>> Alternatively, some clouds provide the ability to run code on a regular 
>>> basis. If your Django code is not closely coupled with cron job, you could 
>>> use AWS Lambda. 
>>> 
>>> https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html 
>>> 
>>> If it is tightly coupled and Celery is too powerful for your needs, you 
>>> could use an AWS Lambda (or Azure Function, etc) to send a request to your 
>>> Django API on a regular basis. 
>>> 
>>> Andrew 
>>> https://jambonsw.com 
>>> https://django-unleashed.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 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/73e3ded5-45be-4185-95e5-968ef803c75b%40googlegroups.com.
>> 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/jyDsSmwc1Lk/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 
> https://groups.google.com/d/msgid/django-users/CAA%3Diw_9SAgunm1_0qSTi8mqAGwmS2pJNNwRm2HO4kYTUHGA7zw%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/69CEDE8E-1B0C-486C-82A9-7732231ACD06%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trigger actions independently of url request

2018-10-22 Thread Charley Paulus
Hi Andrew,

Thank you for your answer.

To better clarify my need, here is one use case:
1) I would like my server (where Django is) to ping a remote address (let's 
say google.com) every 10 minutes, and put the result (communication ok or 
not) in a Django-generated database.
2) Then I will have a Django view that displays some statistics based on 
this database records. No worries for this point. My question is strictly 
on point 1.

So what I need is my server itself to run code on a regular basis.
Can I simply start a thread in manage.py, like here: 
https://eldarion.com/blog/2013/02/14/entry-point-hook-django-projects/ ?

It seems that Celery and AWS Lambda are external tools that can remotely 
call my Django API.

I hope the example helps.

Thanks again.

Best regards,
Charley


On Monday, October 22, 2018 at 1:10:52 PM UTC-4, Andrew Pinkham wrote:
>
> On Oct 22, 2018, at 12:08, Charley Paulus  > wrote: 
> > After reading the Django tutorial, my understanding (I hope I’m wrong) 
> is that the only way to trigger a function of a Django app is when someone 
> on the client side request the url related to that function. 
>
> That is correct. A view function/object is only called when a site visitor 
> is routed to that callable by the URL configuration. 
>
> > But what if I want the server to run a function indenpendently of a url 
> call, for example: 
> > - every 10 minutes 
> > - when a pre-defined combination of variables become true 
>
> I'm not clear on your second condition, but you are probably interested in 
> Celery for the first. 
>
> http://www.celeryproject.org/ 
> <http://www.google.com/url?q=http%3A%2F%2Fwww.celeryproject.org%2F=D=1=AFQjCNHFKFryLZKtiOnQPW1ANJ8iUvy_5g>
>  
>
> Alternatively, some clouds provide the ability to run code on a regular 
> basis. If your Django code is not closely coupled with cron job, you could 
> use AWS Lambda. 
>
> https://docs.aws.amazon.com/lambda/latest/dg/with-scheduled-events.html 
>
> If it is tightly coupled and Celery is too powerful for your needs, you 
> could use an AWS Lambda (or Azure Function, etc) to send a request to your 
> Django API on a regular basis. 
>
> Andrew 
> https://jambonsw.com 
> https://django-unleashed.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 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/73e3ded5-45be-4185-95e5-968ef803c75b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Trigger actions independently of url request

2018-10-22 Thread Charley Paulus
Hi,

After reading the Django tutorial, my understanding (I hope I’m wrong) is that 
the only way to trigger a function of a Django app is when someone on the 
client side request the url related to that function.

But what if I want the server to run a function indenpendently of a url call, 
for example:
- every 10 minutes
- when a pre-defined combination of variables become true

Where should such code live?

Thank you.
Best regards,
Charley

-- 
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/7897fc02-62de-49d4-bfc2-9fc874c34fdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.