Re: Aide

2019-07-05 Thread PASCUAL Eric
Google est ton ami : "django mongodb" fournit un tas de réponses à cette 
question, y compris des références à des packages d'extension de Django.

Eric


From: django-users@googlegroups.com  on behalf 
of Djamiyou CHITOU 
Sent: Thursday, July 4, 2019 11:48
To: Django users
Subject: Aide

Salut tous svp! j'aimerais associé mongoDB a django que faire?


--
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/264124aa-b58d-4e1e-8aee-3a7535b08fec%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/AM5P193MB0243AF3B6885497CC70391248CF50%40AM5P193MB0243.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing data from a 30 GB file in json format

2019-07-01 Thread PASCUAL Eric
Hi again,

My bad, UltraJSON is not really suited for event based parsing. I confused it 
with something else.

Yajl C library (http://lloyd.github.io/yajl/) should match better, and has a 
Python binding focusing on stream based processing 
(http://pykler.github.io/yajl-py/), both for parsing and generation.

Eric


From: django-users@googlegroups.com  on behalf 
of PASCUAL Eric 
Sent: Monday, July 1, 2019 17:06
To: django-users@googlegroups.com
Subject: Re: Accessing data from a 30 GB file in json format

Hi,
To be able to traverse the JSON structure you'd normally need the entire 
structure in memory.
Not mandatory, depending whats is to be done with the data.

The same problem exists with XML, and this is the reason why SAX parsers have 
been created in addition to DOM ones.

If the data process can accommodate with on the fly handling, implementing a 
callback based parser could solve the problem. Maybe have a look at projects 
such as Naya, UltraJSON and alike, they could be time (and memory 😉) savers.

HTH

Eric


From: django-users@googlegroups.com  on behalf 
of Cornelis Poppema 
Sent: Monday, July 1, 2019 15:38
To: Django users
Subject: Re: Accessing data from a 30 GB file in json format

To be able to traverse the JSON structure you'd normally need the entire 
structure in memory. For this reason you can't (easily) apply suggestions to 
iterate over a file efficiently to a JSON file: you can perhaps read the file 
efficiently, but the structure in memory will still grow in memory. I've found 
these packages made for efficiently reason large JSON files after a quick 
search: https://github.com/ICRAR/ijson or 
https://github.com/kashifrazzaqui/json-streamer. 
https://stackoverflow.com/a/17326199/248891 shows a simple example when using 
ijson



On Monday, 1 July 2019 12:07:39 UTC+2, Nibil Ashraf wrote:
Hey,

I have a file with a size of around 30GB. The file is in json format. I have to 
access the data and write that to a csv file. When I tried to do that with my 
laptop which has a a RAM of 4GB, I am getting some error. I tried to load the 
json file like this json_parsed = json.loads(json_data)

Can someone help me with this? How should I do this? If I should go with some 
server, please let me know what specifications should I use?

--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/00dd3f6a-85da-4942-97bb-eae2652cfe96%40googlegroups.com<https://groups.google.com/d/msgid/django-users/00dd3f6a-85da-4942-97bb-eae2652cfe96%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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/VI1P193MB02545BE2E774BFA921418F088CF90%40VI1P193MB0254.EURP193.PROD.OUTLOOK.COM<https://groups.google.com/d/msgid/django-users/VI1P193MB02545BE2E774BFA921418F088CF90%40VI1P193MB0254.EURP193.PROD.OUTLOOK.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/VI1P193MB02545BB4C8E557BEF6606FEF8CF90%40VI1P193MB0254.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Accessing data from a 30 GB file in json format

2019-07-01 Thread PASCUAL Eric
Hi,
To be able to traverse the JSON structure you'd normally need the entire 
structure in memory.
Not mandatory, depending whats is to be done with the data.

The same problem exists with XML, and this is the reason why SAX parsers have 
been created in addition to DOM ones.

If the data process can accommodate with on the fly handling, implementing a 
callback based parser could solve the problem. Maybe have a look at projects 
such as Naya, UltraJSON and alike, they could be time (and memory 😉) savers.

HTH

Eric


From: django-users@googlegroups.com  on behalf 
of Cornelis Poppema 
Sent: Monday, July 1, 2019 15:38
To: Django users
Subject: Re: Accessing data from a 30 GB file in json format

To be able to traverse the JSON structure you'd normally need the entire 
structure in memory. For this reason you can't (easily) apply suggestions to 
iterate over a file efficiently to a JSON file: you can perhaps read the file 
efficiently, but the structure in memory will still grow in memory. I've found 
these packages made for efficiently reason large JSON files after a quick 
search: https://github.com/ICRAR/ijson or 
https://github.com/kashifrazzaqui/json-streamer. 
https://stackoverflow.com/a/17326199/248891 shows a simple example when using 
ijson



On Monday, 1 July 2019 12:07:39 UTC+2, Nibil Ashraf wrote:
Hey,

I have a file with a size of around 30GB. The file is in json format. I have to 
access the data and write that to a csv file. When I tried to do that with my 
laptop which has a a RAM of 4GB, I am getting some error. I tried to load the 
json file like this json_parsed = json.loads(json_data)

Can someone help me with this? How should I do this? If I should go with some 
server, please let me know what specifications should I use?

--
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/00dd3f6a-85da-4942-97bb-eae2652cfe96%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/VI1P193MB02545BE2E774BFA921418F088CF90%40VI1P193MB0254.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Django-MQTT

2019-05-21 Thread PASCUAL Eric
Hi Sabuhi,

I wrote something similar a couple years ago, not involving Arduinos but using 
MQTT anyway.

The selected approach consisted in having a MQTT listener, based on paho-mqtt 
lib (https://pypi.org/project/paho-mqtt/), acting as a gateway to a REST API on 
the Django side, based on Django REST Framework. It worked pretty well and I 
have no special remembering of difficulties or trouble.

Hope this helps.

Eric


From: django-users@googlegroups.com  on behalf 
of Sabuhi Shukurov 
Sent: Monday, May 20, 2019 15:01
To: Django users
Subject: Django-MQTT

Hello Python Community!
I would like to to create a connection between the device(Arduino) and web 
server by using the MQTT protocol. As tools, we will use RabbitMQ, Django, and  
Django-channels for web socket. The device should communicate to the server by 
means of message broker in order to pass data to interface and should be 
possible to get back subscription by in case of any change on the interface.
I know them theoretically and cannot apply practically to 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/53b73716-5aeb-4b86-9240-5af2a0be4275%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/HE1P193MB025000E7F0313B4087BB6F4B8C070%40HE1P193MB0250.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Porting Django app

2019-05-19 Thread PASCUAL Eric
Hi,

You can avoid dealing with IPs directly, considering that mDNS is available by 
default on Debian based distros (hence Ubuntu). Thanks to this, the server is 
published as ".local".

mDNS is not installed by default in Windows, but it seems that it changed with 
Windows 10.

Best
Eric


From: django-users@googlegroups.com  on behalf 
of Ganesh Babu 
Sent: Saturday, May 18, 2019 06:11
To: django-users@googlegroups.com
Subject: Re: Porting Django app

i understand what you are saying..  To collect private IP address or create as 
Virtual host in LINUX server, its should available.

On Thu, May 16, 2019 at 3:29 PM RLM 
mailto:ukeplaye...@gmail.com>> wrote:
Hello all.
I eventually will need to put my dedicated Django app on another system
owned by a Public institution. The app correlates each data set of 26
million plus samples to a QR code for each.
Security is major  so nothing can be web based, it must be in house and
disconnected from the external web.

A problem is I'm developing on Linux and Mac and much of the world uses
Windows 10 et al.

Installation of python3, Django, mysql and the app would rely on the IT
people at the institution who do not like installing software on secure
systems.
I would also point out that schools here also fall into the "will not
install that software" category significantly limiting student's ability
to learn modern systems.

I trialed compiling Python3 app to an .exe file, works ok, but am
concerned that P3/Django will not do so.

Bio: I'm in my 70's, been developing web apps for 25 years and do not
want to learn C and C++.

Can anyone advise me how to go about providing the system at minimum
problems for the IT sector of the institution.
Thanks in  advance

Roger

--
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/f68670b3-a75d-61ef-2f5b-61065e5a9f56%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


--
Best Regards
Sri Ganesh Babu.S
Sr. Software Engineer,

Doyen Solutions


--
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/CAJZVxAv1nSpLNett9kTmRKXEVsheePwqXTM2%2BGbE50rqtTW3Mw%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/VI1P193MB02549DE3BADD5219DCE3CAD78C050%40VI1P193MB0254.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Django REST in Docker

2019-04-09 Thread PASCUAL Eric
It seems right.

I suppose that requirements.txt contains the rest_framework package too.

You can check the image content by executing the "pip freeze" command on it 
(docker run  pip freeze). This will tell you of all the packages 
you nee are there.

Eric


From: django-users@googlegroups.com  on behalf 
of Shubham Joshi 
Sent: Tuesday, April 9, 2019 10:54
To: django-users@googlegroups.com
Subject: Re: Django REST in Docker


FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/

On Tue, Apr 9, 2019 at 1:30 PM PASCUAL Eric 
mailto:eric.pasc...@cstb.fr>> wrote:
Hi,

Working in contenerized context does not change anything from other modes.

You just need to include the appropriate pip install command in the Dockerfile, 
so that all the dependencies are installed in the image. They will then 
available to your app the same way they are on you dev machine.

Could you show the content of your Dockerfile to check if there would not be 
some other problem ?

Eric


From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
mailto:django-users@googlegroups.com>> on behalf 
of Shubham Joshi mailto:shub...@tersesoft.com>>
Sent: Tuesday, April 9, 2019 07:30
To: Django users
Subject: Django REST in Docker

I had set up django in Docker, now I am trying to install pip packages , like 
rest_framework and added in installed apps too.
but it throws ModuleNotFoundError: No module named 'rest_framework' , whats the 
generic way of installing the pip packages in existing dockerized django project

--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/656cff9e-50f9-4d5a-bafc-05eaa99778d7%40googlegroups.com<https://groups.google.com/d/msgid/django-users/656cff9e-50f9-4d5a-bafc-05eaa99778d7%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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/AM0P193MB030871AA27CDB1B3923B785E8C2D0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM<https://groups.google.com/d/msgid/django-users/AM0P193MB030871AA27CDB1B3923B785E8C2D0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.


--

Shubham Joshi
Business Developer | Terse Software
M: 8390246938


E: shub...@tersesoft.com<mailto:rajku...@tersesoft.com>
www.tersesoft.com<http://www.tersesoft.com/>
[linkedin]<https://www.linkedin.com/in/rajkumartiwari/> [github] 
<https://github.com/rajqumar>




--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/CAGJdmX63xQ1kS1z_i5MhkXS0hKkno1_fGnfx5344ShpY-aZv3Q%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAGJdmX63xQ1kS1z_i5MhkXS0hKkno1_fGnfx5344ShpY-aZv3Q%40mail.gmail.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 
htt

Re: Django REST in Docker

2019-04-09 Thread PASCUAL Eric
Hi,

Working in contenerized context does not change anything from other modes.

You just need to include the appropriate pip install command in the Dockerfile, 
so that all the dependencies are installed in the image. They will then 
available to your app the same way they are on you dev machine.

Could you show the content of your Dockerfile to check if there would not be 
some other problem ?

Eric


From: django-users@googlegroups.com  on behalf 
of Shubham Joshi 
Sent: Tuesday, April 9, 2019 07:30
To: Django users
Subject: Django REST in Docker

I had set up django in Docker, now I am trying to install pip packages , like 
rest_framework and added in installed apps too.
but it throws ModuleNotFoundError: No module named 'rest_framework' , whats the 
generic way of installing the pip packages in existing dockerized django project

--
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/656cff9e-50f9-4d5a-bafc-05eaa99778d7%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/AM0P193MB030871AA27CDB1B3923B785E8C2D0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Specifying model relationship as string vs concrete model?

2019-04-07 Thread PASCUAL Eric
Hi Mohit,

The only situations where I have used strings are forward declarations or 
potential reference loops.

Intuitively I'd say that referencing models by their name adds a slight 
overhead for class lookup. But since this is supposed to happen only when the 
model definition is loaded (fields are class level attributes), there are 
chances that there is no impact on performances during the application normal 
operation. The impact should be on the application start phase, but it's 
probably neglectable compared to the overall start time.

Since I've never done any real timing about this point, nor studied Django 
source code to identify the real mechanism, I'm strongly interested in other 
opinions... especially if my analysis is wrong 😉

Best

Eric


From: django-users@googlegroups.com  on behalf 
of Mohit Solanki 
Sent: Sunday, April 7, 2019 05:43
To: Django users
Subject: Specifying model relationship as string vs concrete model?

Since Django provides two ways of specifying model relationship,

models.ForeignKey('User') vs models.ForeignKey(User)

Which one is more preferred and recommended? Is there any upside or downside of 
choosing one over the other?  In Django documentation, all the example are of 
the second form but I have seen many people specifying the relationship as a 
string. Can Someone please elaborate more on this?

Regards,

Mohit

--
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/06988f5c-9ad0-47b1-9216-5f689abb1720%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/AM0P193MB0308A3049D2828BB316C4B348C530%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Django inbuilt server

2019-04-03 Thread PASCUAL Eric
Hi,

Chances are that you're thinking about "runserver", which is a management 
command. On Unix based systems (i.e. Linux or MacOS) you start it with :

./manage.py runserver

I'm not exactly sure about Windows, but it should be something as :

python manage.py runserver

Warning : as stressed in the documentation, this is not a server to be used in 
production and it is reserved to development and local tests.

Eric


From: django-users@googlegroups.com  on behalf 
of primeshs...@cse.mrt.ac.lk 
Sent: Tuesday, April 2, 2019 14:36
To: Django users
Subject: Django inbuilt server

Hello, I'm a new django user. Can someone please tell me what is the name of 
django inbuilt server is? I went throughout the internet but I couldn't find a 
proper answer.

Regards.

--
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/1cd87cfb-9b2f-4b02-a2e0-4cb494318532%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/AM0P193MB0308CFC1341078ACDCDBFF388C570%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Venv

2019-04-02 Thread PASCUAL Eric
Hi,

pyenv (https://github.com/pyenv/pyenv) offers a simpler way for 
activating/deactivating venvs, by managing this automatically for you based on 
where you are located in the file tree.

Before focusing on this feature, you must know that pyenv does far more than 
managing virtualenvs, since it lets you manage also different versions and 
implementations (e.g. CPython, PyPy...) of Python interpreter, whatever is the 
ones installed on your system.

This feature is very useful in several situations, among which :

  *   testing a different Python version than the ones installed, without 
taking any risk of tampering your system or needing for a virtual machine
  *   when targeting containerized applications (in which you are free to 
choose whatever Python version you want/need in the container, without any 
concern about the host environment), being able to work in the exact same 
context as the production one

Of course, you can create virtualenvs as usual with pyenv, for any Python 
version installed under its control.

It also lets you set which Python version or virtualenv must be used in a given 
project or workspace. As soon as you cd in the corresponding file tree, pyenv 
will automatically activate the right virtualenv (and deactivate the active one 
if any) and the associated Python interpreter. It does the reverse (i.e. 
deactivating it) when leaving the tree. The magic is done by storing the Python 
interpreter or virtualenv name in a hidden file (namely .python-version) at the 
root of the related file tree. The pyenv shell plugins look for this file by 
climbing the file tree when you navigate in the dirs and does what it has to do 
accordingly.

What's very important is that pyenv does not touch a bit of your system wide 
Python interpreters, but uses a mechanism of shims to masquerade them and 
redirect the flow to installations located under your home dir.

Even if you don't play with different Python version, IMHO pyenv deserves a 
look, if only for its automatic virtualenv switching capability.

PS: I'm not affiliated in anyway with pyenv creators, but just a happy user for 
a while now 🙂

Best

Eric


From: django-users@googlegroups.com  on behalf 
of Gil Obradors 
Sent: Saturday, March 30, 2019 19:35
To: django-users@googlegroups.com
Subject: Re: Venv

You do it: source /bin/activate

Missatge de John mailto:johncrosb...@gmail.com>> del 
dia ds., 30 de març 2019 a les 19:32:
Good evening

I've created and activated venv like this:
$ python3 -m venv 
$ source /bin/activate

Now Ive ‘deactivate’ the venv

How do I re-activate please?

🙏



--
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/EA2E8453-8CF9-4F32-9EB6-D364C71D3FD4%40gmail.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/CAK-JoTQ--pE5AKEDwjmv%2BDV_LuxsZ3U22JSmHUFqavR8qEYWGA%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/AM0P193MB0308591E22210F526E0D36B88C560%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Create models using raw SQL queries

2019-03-28 Thread PASCUAL Eric
Hi Cameron,
the reason why I wanted to use django is that I had used it before and I didn't 
want to have to learn a new framework if possible.
Makes sense.

However, light FWs such as Tornado (which I like a lot, and prefers over Flask 
BTW)  have a really small learning curve for a basic usage (i.e. serving 
dynamic pages with the help of templates). If you're already familiar with 
Django, you'll be productive with Tornado is less than one hour, if not shorter.

If you have the option to invest a bit of time, it deserves a look because 
you'll get the ROI of having one more weapon in your arsenal. You'll thus be 
able to select the best suited option instead of relying on the same one every 
time. Although Django is really great (I work a lot with it for years for my 
job as well as for private projects, and I really enjoy it), there are 
situations it's not the optimal choice. For instance, it can be a bit overkill 
when you don't have to play with a data model justifying an ORM and such.

One important word about Tornado, and why I like it so much : it is based on 
the asynchronous paradigm and despite being single thread and single process 
(although it supports a multi-process execution mode for taking advantage of 
multi-cores CPUs) it is able to serve a lot of requests thanks to this. This is 
especially true when these requests are IO bound (e.g. DB access, network 
requests...). Knowing such an architecture and knowing how to properly 
implement request handlers to leverage its power is IMHO a valuable experience. 
Tornado is amazing when your target is an embedded system with constrained 
resources, such as a Raspberry Pi or alike. I've developed several real world 
apps in this context and it plays amazingly well.

Even if Tornado has not as many batteries included as Django (it brings nothing 
for data access f.i.) it comes with a lot of valuable features inside in 
addition to templating and request serving (CSRF, CORS, sessions, user 
authentication, asynchronous network clients, Web sockets, I18N support, UI 
modules,...). In addition, you don't need to put a WSGI server in front, since 
it includes its own asynchronous production grade server (not a dev server such 
as Django's runserver but a real production one).

Maybe all this looks a bit like Tornado propaganda or Django bashing. It's 
neither of these of course, but only my own experience.

Best regards

Eric


From: django-users@googlegroups.com  on behalf 
of cameron hochbrg 
Sent: Thursday, March 28, 2019 04:46
To: django-users@googlegroups.com
Subject: Re: Create models using raw SQL queries

Thank you for your response. I am aware that django has for purpose to hide the 
SQL. the reason why I wanted to use django is that I had used it before and I 
didn't want to have to learn a new framework if possible.

Le mer. 27 mars 2019 à 21:33, Simon A 
mailto:arriolasi...@gmail.com>> a écrit :
hi Cameron, as Eric said, by doing this you might not fully take advantage of 
the features of django. But if you still want to proceed maybe you can use the 
managed option for models. 
https://docs.djangoproject.com/en/2.1/ref/models/options/#managed.

with this approach, you'll create the database tables manually first OUTSIDE of 
django, then connect django to it afterwards. I haven't tried it before but 
this might be what you need.

also if your teacher requires to perform raw sql queries rather than use the 
ORM, there is an option to use raw sql queries. 
https://docs.djangoproject.com/en/2.1/topics/db/sql/#executing-custom-sql-directly

On Thursday, March 28, 2019 at 6:16:54 AM UTC+8, Eric Pascual wrote:
Hi,

Not sure Django is the right choice in your case since one of its main purposes 
is to hide the SQL stuff by putting the ORM in front.

You'd better use Flask, Tornado or any other Web framework which does not come 
with any special feature WRT data access.

Best

Eric


From: django...@googlegroups.com  on behalf of 
cameron hochbrg 
Sent: Tuesday, March 26, 2019 21:36
To: Django users
Subject: Create models using raw SQL queries

hello,

for a project for a database class, we wanted to create a web app using django. 
However, our teacher wants us to use raw SQL queries for everything involving 
the database. As such I was wondering if it was possible to create mdoels using 
raw SQL queries.

thank you 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...@googlegroups.com.
To post to this group, send email to djang...@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/8145efe7-c169-43d6-86e6-e0d64415a764%40googlegroups.com

Re: Create models using raw SQL queries

2019-03-27 Thread PASCUAL Eric
Hi,

Not sure Django is the right choice in your case since one of its main purposes 
is to hide the SQL stuff by putting the ORM in front.

You'd better use Flask, Tornado or any other Web framework which does not come 
with any special feature WRT data access.

Best

Eric


From: django-users@googlegroups.com  on behalf 
of cameron hochbrg 
Sent: Tuesday, March 26, 2019 21:36
To: Django users
Subject: Create models using raw SQL queries

hello,

for a project for a database class, we wanted to create a web app using django. 
However, our teacher wants us to use raw SQL queries for everything involving 
the database. As such I was wondering if it was possible to create mdoels using 
raw SQL queries.

thank you 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/8145efe7-c169-43d6-86e6-e0d64415a764%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/AM0P193MB03085C88060C9FA76F9FA8338C580%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Django template

2019-02-09 Thread PASCUAL Eric
Hi,

Templates are nothing more than HTML files with special tags inside. In their 
simplest form, they can be plain HTML without any templating tags and they will 
thus be rendered without any change.

In conclusion, to keep it simple and still let you the opportunity to benefit 
from templating features if ever the need arises in the future, let settings as 
they are and follow template view examples. The overhead will be minimal for 
such "static" templates since the engine provides a quite efficient 
preprocessing and caching mechanism and in any case, negligible compared to DB 
or network related stuff.

Anyway, if for any reason you do not want to keep the templating engine in the 
path at all, your views can return basic HTTP responses containing static HTML 
data, either stored as constant strings in your code (not the cleanest option) 
or, better, as resources in your project (e.g. plain files somewhere they can 
be read from the app code).

Best

Eric


From: django-users@googlegroups.com  on behalf 
of Tom Zhang 
Sent: Friday, February 8, 2019 19:59
To: Django users
Subject: Django template

Hi,

If I don't want to use any Django template and I just want to use regular 
html/javascript, how should I setup the template config in settings.py?

Right now, my settings are:

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

Thanks,

Tom


--
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/e88d65e8-c992-4a57-ac5b-3ed5f60dab24%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/AM0P193MB03088A4EC2AEDE3EDCE2C2BE8C6A0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Webinterface for python script

2019-02-07 Thread PASCUAL Eric
Hi Scott,

100% agree with all your points about stock Django. This is BTW the way I use 
it in all my projects. The stripping experiment I mentioned has been done for 
curiosity's sake, for diving a bit into customization if ever I would need it 
some day.

Knowing this, my suggestion about providing indications about how to shrink 
Djagon's footprint is more aimed at reassuring people having doubts about 
Django being suited to their project because looking as "too heavy", by showing 
them that it can be slimmed down if wanted (needed ?).

Best

Eric


From: django-users@googlegroups.com  on behalf 
of Scot Hacker 
Sent: Thursday, February 7, 2019 09:16
To: Django users
Subject: Re: Webinterface for python script



On Wednesday, February 6, 2019 at 1:27:18 AM UTC-8, Eric Pascual wrote:
Hi Derek,
but I have never seen anyone refer to it as a "lightweight" project (before 
you, that is).
I didn't meant "Django is lightweight" but "Django can be lightweight", implied 
you configure it accordingly.

To be clear, I'm talking about stock Django. Out of the box, Django is already 
lightweight for all practical intents and purposes. I've *never* encountered a 
problem with startup time, memory usage, or speed due to Django itself. I don't 
need to remove the ORM or tweak the template layer or anything else. Out of the 
box, Django is already fast. Therefore, I cannot seem to find a use case that 
makes Flask worth all of the additional dev time that it requires worth it.


> What really matters is : "will the job be done ?".


Yep. And quickly. In execution time, there is no metric I care about where 
"Flask wins" but in development time, stock Django is way ahead of Flask.

I agree that what could be added in Django documentation is a section 
explaining how to strip its default application setting down to the minimal 
stuff for equating solutions such as Flask,

No need. Django doesn't need to be stripped down - it's already plenty fast for 
virtually every web project. Even the smallest ones. But as small projects grow 
into large/complex ones, Django has your back while Flask does not.

./s


--
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/8652bc68-3857-4d91-a3ba-8868ec63f636%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/AM0P193MB0308C98AABD248C00D13BFBF8C680%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Use of asyncio

2019-02-06 Thread PASCUAL Eric
Hi,

There has been quite a lot PyCon talks about this topic, including introduction 
ones for people not used to Python async extensions.

You can find  them on YouTube by asking for "pycon asyncio" for instance.

Best

Eric


From: django-users@googlegroups.com  on behalf 
of Andréas Kühne 
Sent: Wednesday, February 6, 2019 17:48
To: django-users@googlegroups.com
Subject: Re: Use of asyncio

Hi Shiva,

This isn't technically a django question - django itself doesn't have asyncio 
support (yet). So I would search on the web for information about how asyncio 
works in Python. I know that Michael Kennedy has a course in asyncio and how it 
works: https://training.talkpython.fm/courses/all

Regards,

Andréas


Den lör 2 feb. 2019 kl 03:39 skrev shiva kumar 
mailto:kannamshivakumar...@gmail.com>>:
Can anyone explain to which applications asyncio used for.

--
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/CAMsYeuHMYhz-m%3D3hr%2BAwzdmOGx3UMr1HNDSYLV-MAWyxtRWZ4A%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/CAK4qSCcCcpZCk4vbmQW2WaODWTW1VuEiBt5w75wqatfV8_EKjg%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/AM0P193MB030828AA6F739488D97488988C6F0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Webinterface for python script

2019-02-06 Thread PASCUAL Eric
Hi Derek,
but I have never seen anyone refer to it as a "lightweight" project (before 
you, that is).
I didn't meant "Django is lightweight" but "Django can be lightweight", implied 
you configure it accordingly.

Of course, leaving in place the ORM, the session management, the authentication 
system, the various protections (CORS, CRSF,...) and all the other middlewares 
configured in the default settings can seem overkill if the need boils down to 
a basic HTML form for uploading some file and used on a local network. But even 
if you leave them in place, is it really a problem ? They will be there, but 
their code will not kick in. So why bother ? Maybe some code will still be 
activated without a real need, but the overhead is ridiculous in front of the 
network time, especially if file upload is involved. The problem described by 
the OP does not seem to be related to a heavy traffic commercial app. So who 
cares with these extra unneeded code being executed ? What really matters is : 
"will the job be done ?".

Having used myself several frameworks (starting from Tornado down to Bottle and 
including Flask to name a few) in real world projects, when coming to writing 
the views (or request handlers, route functions,... depending on the FW 
terminology) I never felt that one of them was simpler or lighter than the 
others on that point, or even superior.

I agree that what could be added in Django documentation is a section 
explaining how to strip its default application setting down to the minimal 
stuff for equating solutions such as Flask, Tornado et al. Maybe it could also 
help having the project creation tool include options to select among different 
scenarios (default like the current one, minimal Web app without ORM,...). 
Newcomers could then adopt Django for their basic projects without fearing 
about this lightweight-ness issue, but being confident that they will be able 
to kick in other features (e.g. the ORM, which is the big chunk of Django, 
probably at the origin of the lightweight-ness question) as their future 
projects will require. The net benefit is that they will not have to switch 
from one FW to another one depending on the project, which means investing in 
several learning curves, being able to switch between their respective 
paradigms... and fixing errors coming from confusing things belonging to the 
different FW they work with 😊

Just my $0.2 😉

Best

Eric

From: django-users@googlegroups.com  on behalf 
of Derek 
Sent: Tuesday, February 5, 2019 14:26
To: Django users
Subject: Re: Webinterface for python script

Hi Eric

Of course I also think Django is great ... but I have never seen anyone refer 
to it as a "lightweight" project (before you, that is).

My use of the word "overkill" was in the context of what how the OP described 
his need.  If he said he wanted to upload data from a spreadsheet and store in 
a DB, then I would offered advice how to do that with Django.

But its a mistake to think that "Python" + "data processing" automatically 
equals Django.

My 2c
Derek


On Tuesday, 5 February 2019 11:04:45 UTC+2, Eric Pascual wrote:
Hi,
I never know what people mean by "Django is overkill for...". Django is 
lightweight and starts up very quickly
You're right WRT the Django technical part.

My feeling is that people implicitly refer to the learning curve, because it's 
the visible part. Django is a very capable framework with batteries included, 
but its documentation is largely ORM-centric (which is logical because of its  
motivations) in addition to being quite voluminous (which is a good point, 
since it covers every tiny bit of  the beast). This can be intimidating when 
people are looking for something very basic which does not require the ORM.

I was among these people until my experience and skills in Django reached the 
level where I became aware that it can be stripped down to a very basic an 
lightweight framework if needed, thanks to its modular approach. But this came 
with time 😉

Best

Eric

From: django...@googlegroups.com  on behalf of Scot 
Hacker 
Sent: Tuesday, February 5, 2019 08:54
To: Django users
Subject: Re: Webinterface for python script

Make a basic Django view. Place your script in a python module that lives 
inside your app. Call that module/ function from the Django view. See Django 
docs and tutorials on how to handle uploaded files. Pass the uploaded file to 
your module, and handle the return value(s) however you want. Hard to get more 
specific than that without seeing your code, but this should come together 
pretty quickly with some experimentation.

I never know what people mean by "Django is overkill for...". Django is 
lightweight and starts up very quickly, even with large/complex projects. 
Django saves you mountains of time compared to Flask, which makes you go 
shopping for every little piece of framework you need. Every time I've 
experimented with Flask, 

Re: Webinterface for python script

2019-02-05 Thread PASCUAL Eric
Hi,
I never know what people mean by "Django is overkill for...". Django is 
lightweight and starts up very quickly
You're right WRT the Django technical part.

My feeling is that people implicitly refer to the learning curve, because it's 
the visible part. Django is a very capable framework with batteries included, 
but its documentation is largely ORM-centric (which is logical because of its  
motivations) in addition to being quite voluminous (which is a good point, 
since it covers every tiny bit of  the beast). This can be intimidating when 
people are looking for something very basic which does not require the ORM.

I was among these people until my experience and skills in Django reached the 
level where I became aware that it can be stripped down to a very basic an 
lightweight framework if needed, thanks to its modular approach. But this came 
with time 😉

Best

Eric

From: django-users@googlegroups.com  on behalf 
of Scot Hacker 
Sent: Tuesday, February 5, 2019 08:54
To: Django users
Subject: Re: Webinterface for python script

Make a basic Django view. Place your script in a python module that lives 
inside your app. Call that module/ function from the Django view. See Django 
docs and tutorials on how to handle uploaded files. Pass the uploaded file to 
your module, and handle the return value(s) however you want. Hard to get more 
specific than that without seeing your code, but this should come together 
pretty quickly with some experimentation.

I never know what people mean by "Django is overkill for...". Django is 
lightweight and starts up very quickly, even with large/complex projects. 
Django saves you mountains of time compared to Flask, which makes you go 
shopping for every little piece of framework you need. Every time I've 
experimented with Flask, I've come running back to Django after realizing my 
time is too valuable to waste it on creating my own framework when a perfectly 
great one already exists.

./s


On Sunday, February 3, 2019 at 7:53:20 AM UTC-8, Asad Hasan wrote:
Hi All ,

  I have created certain python scripts to analyze log files and 
suggest solution based on logic which I invoke on the command line . I need 
some information on how to execute these through browser . I am using :

python test.py file1 file2

How do I use the browser to upload the files file1 and file2 and it process the 
files .

Please advice ,

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/88c2337b-7e8a-4e11-968f-30299b6229d4%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/AM0P193MB03087CA6B3D3BD6621C813188C6E0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Need tutorials

2019-01-22 Thread PASCUAL Eric
Hi,


Start by studying the iintroduction and the tutorial directly available on the 
Django official website. Th will learn you step by step the fundamental 
concepts and how to write a fully working application using a significant share 
of Django features.

Once you'll have assimilated the basics, practice by enhancing the tutorial 
example, or by writing your own application.

Resources such as Django Girls website or Two Scoops of Django book (among a 
lot of other valuable sources of knowledge) are highly suggested too for 
filling the gaps and going one step further.


Have a nice trip discovering the wonderful world of Django ;)


Regards


Eric



From: django-users@googlegroups.com  on behalf 
of Madhav Rajmohan 
Sent: Saturday, January 19, 2019 4:30:55 AM
To: Django users
Subject: Need tutorials


Guys,
   I've Heard that django helps you create  something that is 
mesmerizing form your mind and I've heard that you guys can help me bring up my 
basics.I Am just a Beginner and I Need your help


 -Madhav Rajmohan

--
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/87f8f462-2fc6-4d68-8170-e8f98871a2e3%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/AM0P193MB030800AE2C7038D1D4FBA1458C980%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Lot into existing Django site

2019-01-17 Thread PASCUAL Eric
Hi,


Since you'll need to update the files on the server, you must have a write 
access to it.

Usually, FTP is no more activated on servers, because not secure at all. This 
can be the reason why the access is denied. There should be an ssh access 
available, so that you can connect on the server and also transfer files 
to/from it, via the scp command. But you must know the appropriate credentials 
(i.e. login/password) or have the keys if ever the password based 
authentication has been deactivated in favor of the ssh-keys based mechanism.

Anyway you have to be in touch with people who have installed the server and 
deployed the application on it, since there are the only ones who can provide 
the above mentioned information.


Regards


Eric



From: django-users@googlegroups.com  on behalf 
of TheShoff 
Sent: Tuesday, January 15, 2019 10:03:07 PM
To: Django users
Subject: Lot into existing Django site

I am trying to add reCaptcha to an existing Django website that was created by 
a company we no longer work with. I have server access to the website, but 
cannot figure out how to edit the files or add the reCaptcha form (I tried to 
manually add the code into the HTML and .py files and uploading it on my FTP 
client and was denied access). Do I need to login to the website using Python 
to add the reCaptcha form? If so, can someone tell me how? I am not looking to 
make any other changes at this time.

***Please note I am new to Django and trying to figure out how it works.***

--
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/bc358bef-40b7-41e2-8faf-39cd89b1f339%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/AM0P193MB03082DB4E967653D1D4044F48C830%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: channnels -- communication with redis

2019-01-15 Thread PASCUAL Eric
Hi,


How is configured your Docker stack exactly ? You should have several 
containers in it, at least one for the Redis server, another one for the Django 
app.


Do you use docker-compose to run the stack ? If yes, could you provide the YAML 
descriptor of the stack ?


Best


Eric



From: django-users@googlegroups.com  on behalf 
of Yuval Bachrach 
Sent: Tuesday, January 15, 2019 5:31:18 PM
To: django-users@googlegroups.com
Subject: channnels -- communication with redis


I fail to have django channels communication with redis running at docker 
container: I am running the channels tutorial and I get an error when just 
following the tutorial instructions.


I am quite new with Django (designed a simple site) and have no knowledge on 
redis nor docker


I am trying to lean channels using the tutorial: 
https://channels.readthedocs.io/en/latest/tutorial/

It uses redis over docker



At tutorial part 2 there is a test for “channel layer can communicate with 
Redis”.

I fails this test. I was looking over the web for solving this communication 
problem with no luck.

As I am not familiar with redis nor docker, I have hard time analyzing the 
reasons for the communication problems. I can see that redis is running inside 
a docker container.



$ docker ps

CONTAINER IDIMAGE   COMMAND  CREATED
 STATUS  PORTS

 NAMES

2bdabc272ec3redis   "docker-entrypoint.s…"   About an hour 
ago   Up About an hour0.0.0.0:6379->6379/tcp

 quizzical_panini

$ docker inspect quizzical_panini > redisimage.log

  (YB: will paste the logfile at the end of this  message)





python manage.py shell

import channels.layers

channel_layer = channels.layers.get_channel_layer()

from asgiref.sync import async_to_sync

async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})

Error begins with:

In [4]: async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})

---

ConnectionRefusedErrorTraceback (most recent call last)

 in 

> 1 async_to_sync(channel_layer.send)('test_channel', {'type': 'hello'})

A lot of other details. Ends up with:

504 # Jump to any except clause below.

--> 505 raise OSError(err, f'Connect call failed {address}')

506 except (BlockingIOError, InterruptedError):

507 # socket is still registered, the callback will be retried 
later



ConnectionRefusedError: [Errno 10061] Connect call failed ('127.0.0.1', 6379)



Some version details:

installing shell command:

$ docker run redis --version

Redis server v=5.0.3 sha=:0 malloc=jemalloc-5.1.0 bits=64 
build=9f27eb593282148b

$ pip install channels_redis

A lot of details: ends up with:

> Successfully installed channels-redis-2.3.3

$ python --version

Python 3.7.1

(note that it is a 32 bit python while docker requires 64 bits. I assumed it 
should not be the reason for the problems I do experience



 redisimage.log generated by docker inspect as shown above <<

 It is long. I can’t tell id/what is relevant

[

{

"Id": 
"2bdabc272ec364e6b34a40e253d089e48b73d55cddcade1d51b70c202aad6479",

"Created": "2019-01-15T14:02:36.679774957Z",

"Path": "docker-entrypoint.sh",

"Args": [

"redis-server"

],

"State": {

"Status": "running",

"Running": true,

"Paused": false,

"Restarting": false,

"OOMKilled": false,

"Dead": false,

"Pid": 8731,

"ExitCode": 0,

"Error": "",

"StartedAt": "2019-01-15T14:02:37.086931139Z",

"FinishedAt": "0001-01-01T00:00:00Z"

},

"Image": 
"sha256:5d2989ac9711b6c7a96dfca3110041d6259294f5ccd343491ecfffe3d14757cc",

"ResolvConfPath": 
"/mnt/sda1/var/lib/docker/containers/2bdabc272ec364e6b34a40e253d089e48b73d55cddcade1d51b70c202aad6479/resolv.conf",

"HostnamePath": 
"/mnt/sda1/var/lib/docker/containers/2bdabc272ec364e6b34a40e253d089e48b73d55cddcade1d51b70c202aad6479/hostname",

"HostsPath": 
"/mnt/sda1/var/lib/docker/containers/2bdabc272ec364e6b34a40e253d089e48b73d55cddcade1d51b70c202aad6479/hosts",

"LogPath": 
"/mnt/sda1/var/lib/docker/containers/2bdabc272ec364e6b34a40e253d089e48b73d55cddcade1d51b70c202aad6479/2bdabc272ec364e6b34a40e253d089e48b73d55cddcade1d51b70c202aad6479-json.log",

"Name": "/quizzical_panini",

"RestartCount": 0,

"Driver": "overlay2",

"Platform": "linux",

"MountLabel": "",

"ProcessLabel": "",

"AppArmorProfile": "",

"ExecIDs": null,

"HostConfig": {

"Binds": null,

"ContainerIDFile": "",

"LogConfig": {

 

Re: To learn proper project based Django .

2019-01-15 Thread PASCUAL Eric
Hi,


The Django official website includes an extensive reference documentation and a 
detailed tutorial. This is the preferred start point.


Afterwards, you can grab complements from resources such as  :

  *   Django Girls site
  *   Two Scoops of Django book


These are those which came out of my mind, but there are plenty others.


BTW Two Scoops is a great book which goes beyond Django itself, and provides 
advice about how to structure a Django project, which extensions and tools are 
useful,... It's a very valuable source of inspiration to build your own 
experience. Just be warned that it refers to Django 1.11 (and not yet Django 
2.x), but this should not be a real problem for now.


Once you'll have assimilated the content of theses sources, you'll be very well 
prepared for Django coding ;)


Regards


Eric


From: django-users@googlegroups.com  on behalf 
of Nikhil kanamadi 
Sent: Tuesday, January 15, 2019 10:38:09 AM
To: django-users@googlegroups.com
Subject: To learn proper project based Django .

Hi all,

I am one year experienced software professional.
Worked on python and flask.
But now I need to learn And build hands-on Django projects.
Which is best source for project based understanding  and learning.

Please provide me any free hands-on  bootcamps  or sources.

--
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/CAJruv46usXAMXUXukt7%2BsGuMSib1JMdTVL_04zd7EQt0tQ3CZA%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/AM0P193MB0308D44E73EE3A85D2ADC7F08C810%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Where do you place your application code in production

2019-01-14 Thread PASCUAL Eric
Hi,


It depends on the type of deployment you use.


The options I use are :


  *   for deployment on a "bare server", I create a standard user which id is 
used for running the application, and the application code is stored under the 
home dir of this user. This solves the security problem of running the 
application with a user having the lowest possible privileges
  *   for Docker based deployments, I place most of the time the application in 
a directory directly at the root of the file system of its container (e.g. 
"/app"). No need to bother with standard user home dir or conventions commonly 
used in Linux  FHS (involving places such as /usr or /opt), since the container 
host your stuff only. Not directly related to the topic, but in containers 
also, it's wiser to run the application under a standard user identity.


Hope this helps

Regards

Eric



From: django-users@googlegroups.com  on behalf 
of vineeth sagar 
Sent: Monday, January 14, 2019 9:52:26 AM
To: django-users@googlegroups.com
Subject: Where do you place your application code in production

Hi,

This is not concerned with django itself, but I would love to get the general 
consensus here, In my college days while deploying a php application all the 
tutorials pointed to place my code in /var/www or something of that sort. For 
my django applications I tend to put it in /home//services/. What are the 
potential drawbacks of placing it inside home? Where do you generally place you 
application code?



regards
Vineeth

--
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/CAMMZq8NuE_M0nrU0Hxt7oeFuTVOZNJbgDL%2BAL5vM%3D9SL6T2uJg%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/AM0P193MB0308B6CFE7A51627D2ABB5128C800%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Logging debug & error messages to file

2019-01-12 Thread PASCUAL Eric
Hi,


That way you don't have to deal with rotating log files (not sure if

djangos file logger handles that though) and permission problems.

There is no "Django logger". Django uses the Python native logging module. This 
module defines several handler types, including the RotatingFileHandler one, 
which takes care of rotating logs files automatically on systems which don't 
support this out of the box (Windows for instance). Have a look at 
https://docs.python.org/3.7/library/logging.handlers.html#rotatingfilehandler 
for detail.


However, if your application is supposed to be deployed and executed on *nix 
servers, just log to standard files (or to stdout/stderr and redirect them to a 
log file) and add the involved log files in the logrotate configuration (see 
https://linux.die.net/man/8/logrotate). logrotate takes care of a lot of 
things, such as :

  *   rotating files
  *   purging oldest ones
  *   compress oldest ones

All these actions can be freely configured based on your retention policy for 
logs.


logrotate is rock solid and at the heart of *nix since ages.


Best


Eric



From: django-users@googlegroups.com  on behalf 
of Kasper Laudrup 
Sent: Saturday, January 12, 2019 2:14:39 PM
To: django-users@googlegroups.com
Subject: Re: Logging debug & error messages to file

Hi Uri,

On 12/01/2019 11.34, אורי wrote:
> I'm trying to log debug & error messages to a file. But I receive this
> exception on the server:
>
> ValueError: Unable to configure handler 'file': [Errno 13] Permission
> denied: '/var/log/speedy_net_django.log'
>

The user running django does not have write access to '/var/log'. This
is a good thing. You could give the user running django write access to
'/var/log' or run django as another user, but I definitely wouldn't
recommend that.

> If I change the path to '/tmp/speedy_net_django.log' then it works.
>

That's because every user on the system has write access to '/tmp'.

> How do I configure the server to write messages
> to '/var/log/speedy_net_django.log'? We use Ubuntu and nginx.
>

You could create a directory under '/var/log', eg. '/var/log/speedy_net'
and give the user/group your running django as write access to that
directory and write your logs to '/var/log/speedy_net/django.log'.

> Our logging settings:
> https://github.com/speedy-net/speedy-net/blob/staging/speedy/core/settings/base.py
>
> By the way, are there friendlier ways to view logging messages than with
> text files?
>

Yes indeed. A much better solution would be to use the log system
already available on the system (eg. syslog or journald).

That way you don't have to deal with rotating log files (not sure if
djangos file logger handles that though) and permission problems.

Something like this might be useful:

https://www.simonkrueger.com/2015/05/27/logging-django-apps-to-syslog.html

Kind regards,

Kasper Laudrup

--
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/a872ce04-115d-ec66-de7a-1a0212308d31%40stacktrace.dk.
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/AM0P193MB03081CFA385BDABBE8354B038C860%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: django use models from outside script

2019-01-05 Thread PASCUAL Eric
The simplest way to do this is implementing a custom admin command, which will 
be invoked then with :
./manage.py my_awesome_command


It will take care for you of setting the Django environment (i.e. updating the 
Python path so that the apps are included in it, applying settings and making 
your apps available to the command).

Have  a look here for detail :
https://docs.djangoproject.com/en/2.1/howto/custom-management-commands/


Eric



From: django-users@googlegroups.com  on behalf 
of Samuel Muiruri 
Sent: Saturday, January 5, 2019 1:52:04 PM
To: Django users
Subject: django use models from outside script

I have an external script that I want to have access to django's models 
primarily because it's an external implementation of sockets which is simple I 
want to see if this is possible.

This is the snippet of code I added below the settings.py file based on an 
answer on stackoverflow.

#Allow Django to be used externally
from django.conf import settings
settings.configure(
DATABASES={
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
},
},
#TIME_ZONE='America/Montreal',
)

and at the start of my separate script named `path.py` I did the following 
imports

import django

import pixelart.settings

os.environ.setdefault(
"DJANGO_SETTINGS_MODULE",
"pixelart.settings"
)
django.setup()

from gallery.models import ThumbnailCache, Area, Color

### Note: My django project is called pixelart with a model gallery I'm 
importing models from.

When I try to run the script I get the following error:

(pixelart) sam@sam-Lenovo-G51-35:~/code/pixelart$ python path.py
Traceback (most recent call last):
File "path.py", line 23, in 
from gallery.models import ThumbnailCache, Area, Color
File "/home/sam/code/pixelart/gallery/models.py", line 2, in 
from django.contrib.auth.models import User
File 
"/home/sam/code/envs/pixelart/lib/python3.6/site-packages/django/contrib/auth/models.py",
 line 3, in 
from django.contrib.contenttypes.models import ContentType
File 
"/home/sam/code/envs/pixelart/lib/python3.6/site-packages/django/contrib/contenttypes/models.py",
 line 134, in 
class ContentType(models.Model):
File 
"/home/sam/code/envs/pixelart/lib/python3.6/site-packages/django/db/models/base.py",
 line 95, in __new__
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class django.contrib.contenttypes.models.ContentType 
doesn't declare an explicit app_label and isn't in an application in 
INSTALLED_APPS.

One suggestion I've found based on [this question][1] is to add the sites to 
the installed apps and the site_id.

After trying this out and doing a migration the error remained the same.


  [1]: 
https://stackoverflow.com/questions/35388637/runtimeerror-model-class-django-contrib-sites-models-site-doesnt-declare-an-ex

To be clear  I have an actual django model with a file called path in the main 
project directory. since I'm running them separately i.e. one one terminal 
python manage.py runserver and on another python path.py the path creates the 
sockets. And since some of the data created would best be stored in a model I 
need the path file to access the model.

--
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/d6c32914-e42f-48a3-bf59-c2835006e4bc%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/AM0P193MB0308F2FE55D3AB319B4758F98C8F0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: quête de directives

2019-01-05 Thread PASCUAL Eric
Bonjour,


pip install django


et un petit tour dans la documentation de Django ne ferait pas de mal, car ce 
point est couvert ici :

https://docs.djangoproject.com/en/2.1/intro/install/


Eric



From: django-users@googlegroups.com  on behalf 
of Moise Sacko 
Sent: Saturday, January 5, 2019 1:48:37 PM
To: Django users
Subject: quête de directives

Bonjour à tous et toute. je voudrais avoir des directives pour l'installation 
de Django. Merci d'avance


--
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/f2d4c7fc-d65c-4002-a181-9c60aa1348fc%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/AM0P193MB030838E7AB677C4CC693A7BC8C8F0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Best way to submit application cmd, then download a resulting file?

2019-01-03 Thread PASCUAL Eric
Hi Chris,


The problem you describe does not require Django at all to be solved.


WRT process parameter input, what you need here is a simple Web based UI with a 
basic form. Of course Django can do it, but if you don't need features such as 
the ORM, admin... you can implement it with a couple of lines using lighter 
frameworks (e.g. Tornado).


The point about monitoring  the process requires first that this process is 
able to provide a feedback on demand. On *nix systems, this can be done by 
handling one of the USR signals (e.g. SIG_USR1) and of course implementing the 
process in non blocking mode (to be able to handle the USR signal while 
computing).


How the feedback is returned to the end user is another story. Real time 
feedback in Web apps is preferably done using Web sockets (rather than polling 
periodically the server from JS code on the UI page). Who will push the 
feedback on the socket ? It can be the computation process itself, supposing 
appropriate connection information are passed to it. But it is cleaner to 
separate concerns and isolate this in a monitoring specialized layer, 
communicating with the computation process via Unix sockets for instance or 
capturing its stdout and grabbing dedicated messages in it (e.g. a message like 
"PROGRESS: 30"). One option for implementing this monitor is using job Queues, 
as provided in the multiprocess part of Python standard lib. One you also use 
Celery, RQ or any job queue framework, but chances are that this would be 
overkill (especially Celery). RQ is maybe a good choice here, since very 
lightweight and having RabbitMQ as its only dependency.


Hope this helps


Regards

Eric



From: django-users@googlegroups.com  on behalf 
of Chris Robinson 
Sent: Wednesday, January 2, 2019 10:05:39 PM
To: Django users
Subject: Best way to submit application cmd, then download a resulting file?

Hello,

I'm going to attempt to generalize my question to make this easier to answer.

Lets say I have a simple terminal based application (e.g. multiply_by_two) that 
takes a number argument, then multiplies that number by 2, and returns the 
result into a result.txt file.

I would enter something like this:
multiply_by_two -n 6

The -n flag asks what number I would like to multiply by 2. The result of this 
would be a result.txt, containing the number 12 inside.


What I would like to do is develop a simple Djano application that contains a 
text field allowing me to input the number 6, then click "Submit."

This job will start on the server by running my custom multiply_by_two 
application with my input parameter (6), but when the job is finished and the 
result.txt is available, the browser will automatically download the file.

To make this a tad bit more complex, lets say that the job takes 2 minutes to 
run. What would be the best way to monitor the job? Maybe I accidentally close 
the window.

Not looking for anyone to solve this, I'm just new to Django and want to know 
if someone can give me any pointers on where to start. Are there any apps 
existing that will help me not need to write everything from scratch, 
especially if 'monitoring' is needed? Would Celery be ideal for this?

Thanks for any input!

Regards,
Chris


--
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/6ba9ac84-366c-4c91-b068-3ecc65c27a9d%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/AM0P193MB030870706B6BD352ED1D42E88C8D0%40AM0P193MB0308.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Is Django logging multi-process safe?

2018-12-22 Thread PASCUAL Eric
I do not  have the details in mind, but in the context of a former  Docker 
based deployment, we have used the ELK stack to manage the logs of the 
containers, by capturing the containers' stdout. Thanks to this option, it has 
been possible to stay with basic stream based logs.


If you are interested, I can try to retrieve the exact procedure, but I can't 
promise : it was for the first deployment of this app, which was hosted on 
Azure at that time. Since then we have moved to a Kubernetes managed solution 
on GCP.


BTW we have kept using stream based logs, GCP log tooling offering the 
appropriate tools for exploiting them.


Regards


Eric



From: django-users@googlegroups.com  on behalf 
of Dan Davis 
Sent: Friday, December 21, 2018 11:00:17 PM
To: django-users@googlegroups.com
Subject: Re: Is Django logging multi-process safe?


Eric, thanks for confirming.  I've written my share of logrotate.d files, but I 
may push to do something else, like send them directly to Elasticsearch with a 
delay of some sort.


On Fri, Dec 21, 2018 at 2:00 PM PASCUAL Eric 
mailto:eric.pasc...@cstb.fr>> wrote:

Hi,


If you are running on a Linux system, you'd better using the standard stream 
logs and logrotate to manage file rotating.


The later is the blessed tool for this kind of task, since it manages for free 
the compression of rotated files and removal of oldest ones if you want to.


Regards


Eric



From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
mailto:django-users@googlegroups.com>> on behalf 
of Dan Davis mailto:dansm...@gmail.com>>
Sent: Friday, December 21, 2018 5:55:35 PM
To: Django users
Subject: Re: Is Django logging multi-process safe?

Looks like I should use a WatchedFileHandler and then have logrotate do the 
logging.   If the file pointer is moved by another process, then it will work.
Does gunicorn patch this for me?   Will I be better off using syslog or 
something?

On Friday, December 21, 2018 at 11:51:16 AM UTC-5, Dan Davis wrote:

I just came across this:

https://docs.python.org/3.5/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes

This suggests that log messages sent to a StreamHandler will be processed 
properly, but log messages sent to a standard 
logging.handlers.TimedRotatingFileHandler are not process safe.

What sayeth the group?


--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/b1792c98-0373-42e6-93ac-8b0961ec83e6%40googlegroups.com<https://groups.google.com/d/msgid/django-users/b1792c98-0373-42e6-93ac-8b0961ec83e6%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/1E1MuO08okk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
django-users+unsubscr...@googlegroups.com<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/AM6P193MB042177E51A91076EAC03931E8CB80%40AM6P193MB0421.EURP193.PROD.OUTLOOK.COM<https://groups.google.com/d/msgid/django-users/AM6P193MB042177E51A91076EAC03931E8CB80%40AM6P193MB0421.EURP193.PROD.OUTLOOK.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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/CAFzonYY5_uOiwn7xZUSzqKA3AX6J0V8TPD%2BRRZ%2B%3DdS5OpixGcw%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAFzonYY5_uOiwn7xZUSzqKA3AX6J0

Re: Is Django logging multi-process safe?

2018-12-21 Thread PASCUAL Eric
Hi,


If you are running on a Linux system, you'd better using the standard stream 
logs and logrotate to manage file rotating.


The later is the blessed tool for this kind of task, since it manages for free 
the compression of rotated files and removal of oldest ones if you want to.


Regards


Eric



From: django-users@googlegroups.com  on behalf 
of Dan Davis 
Sent: Friday, December 21, 2018 5:55:35 PM
To: Django users
Subject: Re: Is Django logging multi-process safe?

Looks like I should use a WatchedFileHandler and then have logrotate do the 
logging.   If the file pointer is moved by another process, then it will work.
Does gunicorn patch this for me?   Will I be better off using syslog or 
something?

On Friday, December 21, 2018 at 11:51:16 AM UTC-5, Dan Davis wrote:

I just came across this:

https://docs.python.org/3.5/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes

This suggests that log messages sent to a StreamHandler will be processed 
properly, but log messages sent to a standard 
logging.handlers.TimedRotatingFileHandler are not process safe.

What sayeth the group?


--
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/b1792c98-0373-42e6-93ac-8b0961ec83e6%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/AM6P193MB042177E51A91076EAC03931E8CB80%40AM6P193MB0421.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Django and OpenCV

2018-12-19 Thread PASCUAL Eric
Hi,


What do you mean exactly by "opencv app" ?

If you are referring to some kind of interactive app popping up windows to 
display results of processing, or using the associated event loop, there are 
great chances you cannot for obvious reasons (number one being that there is no 
graphical desktop environment on servers).

But if you mean "use image processing algos from the OpenCV lib", then the 
answer is "it depends". If the involved OpenCV features do not depend on stuff 
provided by, or depending on, the desktop environment and which cannot be 
installed out of this context, there are chances you'll be able to. For 
instance, a lot of people have developed OpenCV based apps for targets such as 
a RaspberryPi running with the headless (aka "server") version of Raspbian (the 
Debian RaspberryPi flavor).

Try googling with "opencv headless" or "opencv server" and you'll get a good 
deal of information. A guy has posted an article titled "Turn your OpenCV Code 
into a Web API in under 10 minutes" 
(https://www.learnopencv.com/turn-your-opencv-code-into-a-web-api-in-under-10-minutes-part-1/).
 It should provide you interesting stuff too (I didn't watch at it at it is 3 
years old now, so I can't say if it is really valuable or not nowadays).
[https://www.learnopencv.com/wp-content/uploads/2015/02/PythonAnywhereAddNewApp.jpg]

Turn your OpenCV Code into a Web API in under 10 minutes — Part 1 | Learn 
OpenCV - Learn OpenCV ( C++ / Python 
)
www.learnopencv.com
Let’s lay down the goals of this tutorial first. We will create a Web API that 
allows a user to call your OpenCV code. We will build a simple example in under 
10 minutes.


HTH

Regards

Eric


From: django-users@googlegroups.com  on behalf 
of odinukwezebr...@gmail.com 
Sent: Sunday, December 16, 2018 3:09:06 AM
To: Django users
Subject: Django and OpenCV

Can I wrap opencv app inside the Djanngo framework, to build an object 
detection app. If yes please tell me how


--
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/dbdeadbf-e18b-4028-b6ad-72b01579139b%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/VI1P193MB0432F071F99CA597D46083DF8CBE0%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Django in Linux set image

2018-12-10 Thread PASCUAL Eric
Hi,


Which server are you using ? Is is runserver ?


When running in debug mode, it serves statics, but not when debug mode is 
turned off.

If you Google with "django runserver static debug" you'll get this hit in the 
very first ones :
https://stackoverflow.com/questions/5836674/why-does-debug-false-setting-make-my-django-static-files-access-fail


The thread explains all the details and gives pointers to the reference 
documentation.


BTW, never use runserver in production. It is not done for that at all, for 
performances and security reasons.


Additionally, as explained in Django doc, statics should not be served by the 
Django app, but by the reverse proxy such as Nginx, which sits in front of the 
Django app and routes requests to the WSGI server, while serving directly 
static assets such as img, js, css...


An other option for statics if you don't want to dive too much into your 
reverse proxy settings for configuring the static routing is to use Django 
middlewares such as whitenoise (http://whitenoise.evans.io/en/stable/), which 
does a quite good job for static serving optimization. This should suffice for 
sites not too much demanding in terms of traffic.


Best regards


Eric


From: django-users@googlegroups.com  on behalf 
of pujiarahman 
Sent: Monday, December 10, 2018 3:28:19 AM
To: Django users
Subject: Django in Linux set image

Hi all,

i have instaled django in ubuntu,
i have image and i put in folder (img), the locate is

blog
urls.py
views.py
admin.py
--static
-- blog
-dist
---img

When i load my browser The image is fine no problem, the problem is when,
i config the settings.py  to :

DEBUG = False
ALLOWED_HOSTS = ['localhost', '27.0.0.1', 'xxx.xxx.xxx.xxx', '[::1]']

the image can not found, but when i set Debug to True , the image come back 
normal.
is there any miss in my config settings.py

this my home.html

{% load static %}









NOC
Member since Nov. 2018


..


Regards

Sidik


--
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/7b30d6a2-c1e0-45fb-8722-3b38ed6fd062%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/VI1P193MB0432DDD00D4084DC21234D968CA50%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Direction Distance measure in python code

2018-12-09 Thread PASCUAL Eric
Hi,


What are you looking for exactly ? Computing the distance on ground between two 
points, based on their geographical coordinates ?


If yes, this is not related to Django, nor to Python in any way. Google with 
keywords such as "geographic coordinates distance computation" and you'll get 
tons of hits, among which this one : 
https://en.wikipedia.org/wiki/Geographical_distance

[https://upload.wikimedia.org/wikipedia/commons/4/4c/Azimutalprojektion-schief_kl-cropped.png]

Geographical distance - 
Wikipedia
en.wikipedia.org
Geographical distance is the distance measured along the surface of the 
earth.The formulae in this article calculate distances between points which are 
defined by geographical coordinates in terms of latitude and longitude.This 
distance is an element in solving the second (inverse) geodetic problem


Transcribing the formulas in Python is left as an exercise, since pretty 
trivial.


Best


Eric


From: django-users@googlegroups.com  on behalf 
of Dheeraj Kumar 
Sent: Sunday, December 9, 2018 2:52:37 PM
To: django-users@googlegroups.com
Subject: Direction Distance measure in python code

Hi can any one tell how can i get distance measure in direction wise
N3 W4 S8 E4 N5
here n is north, w is west , s is south , e is east , n is north
please tell python Django code


--
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/CANwUEV_m%2BaN3X%3Dr-Ltq2eKR7Yx%2BhA1gvv%3DtaazyvqRFLjUVEXQ%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/VI1P193MB0432D362B7B443EB29428FC58CA40%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: I'm new in Django. please help me out

2018-11-13 Thread PASCUAL Eric
> hey, you need to pay for that.


Seen quite frequently : some of the visitors of community groups such as this 
one confuse them with "do_my_job_for_free.com" or "do_my_homework.com" 😊


Eric


From: django-users@googlegroups.com  on behalf 
of amit pant 
Sent: Tuesday, November 13, 2018 10:27:13 AM
To: django-users@googlegroups.com
Subject: Re: I'm new in Django. please help me out

hey, you need to pay for that.

On Tue, Nov 13, 2018 at 2:55 PM mailto:talk...@gmail.com>> 
wrote:
Hi All,

can you please solve this.

1) Create a simple Category model using DRF with following fields :
Id,name,parent,is_featured,image,is_active,description
2) Create CRUD APIs for the same.
3) Validate input at every event/API.
4) Implement ordering and filtering.
5) GET API should take params to return :
Ex. 
/abc.com?params=id|name|is_featured
 : this should return Array of JSON
object with specified keys, along with an authenticated key mentioning user
authentication status.

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/dfdb2b20-66a3-4e56-b548-45c0f59a48ee%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/CAF2Ah_FcL0UEGVFhJBE_nCdCHXFTQyWbzmqPbPV5v13k04r_6A%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/VI1P193MB043255EC430059412851527A8CC20%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Toby McGuire

2018-11-12 Thread PASCUAL Eric
370 assembler


So I'm not the last dinosaur still alive and having written 370 ASM stuff in 
his former life 😃


Sure Django and Python are a big step from there, and welcome aboard ;) Which 
kind of project do you plan to work on, and what are your questions ?


Eric


From: django-users@googlegroups.com  on behalf 
of toby mac 
Sent: Monday, November 12, 2018 6:02:52 PM
To: Django users
Subject: Toby McGuire

Im a newbie to this. Used to program on COBOl, Fortran and 370 assembler, plus 
many others

--
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/3cb81086-f190-41d6-889d-cda899e86b34%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/AM6P193MB042193937FAB7EF71A2BE9C08CC10%40AM6P193MB0421.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: How do I store details securely with django?

2018-11-12 Thread PASCUAL Eric
Hi Lance,


Well, I was off topic. Sorry for this :/ I understand your need better now.


There are chances you've already thought to this option, but what about storing 
the sensitive data encrypted with a key based on a passphrase the user must 
provide when logging, in addition to the usual credentials ? This passphrase 
would not be stored anywhere, so even if the DB is compromised, the sensitive 
data would not be usable.


Eric


From: django-users@googlegroups.com  on behalf 
of Lance Haig 
Sent: Monday, November 12, 2018 4:45:50 PM
To: django-users@googlegroups.com
Subject: Re: How do I store details securely with django?


Hi Eric,

I am sure I have not explained myself properly.

The app does the following.

It presents a user the ability to sign up to a cloud platform for a sandbox / 
playground account.
The number of cloud services that are available will change over time.

Each cloud platform has a set of credentials (username, password, domain 
etc...) These credentials will have elevated permissions within their own 
environments and so should be kept as safe as possible.

Currently I use secrets and .env files to provide these credentials.
This requires physical access to the platform to add new secrets etc...

I want to enable editing (e.g. CRUD on the platform credentials) without having 
to redeploy the application or update the secrets.
The idea was to enable an admin interface to the DB so that each cloud platform 
admin could add more or delete their platform from the solution.
This requires a place to store secrets that can be updated deleted and created.
I was hoping that there might be a standard way to store these that is secure 
other than adding secrets or updating the .env file.

Thanks for trying to understand my vague question.

Lance



On 11/12/18 10:04 AM, PASCUAL Eric wrote:

Hi Lance,


 but I need for people who are admins for a particular cloud to add their cloud 
details to the app and then store their credentials securely.


I'm not sure to understand the need for adding cloud details to the app for the 
admins.


The suggestion I made assumed that sensitive information is managed as K8S 
secrets. As long as the admins have GCloud (for instance) credentials set 
(which are stored and managed at GCloud level), they can administrate the 
secrets resources by "applying" the corresponding YAML descriptors remotely 
from their workstation. The sensitive values are thus stored nowhere inside the 
application itself, but passed to the containers at runtime as environment 
variables.


Maybe I've misunderstood your need and sorry in this case if my answer is off 
topic.


Best


Eric


From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
<mailto:django-users@googlegroups.com> on behalf 
of Lance Haig <mailto:lnh...@gmail.com>
Sent: Monday, November 12, 2018 9:07:30 AM
To: django-users@googlegroups.com<mailto:django-users@googlegroups.com>
Subject: Re: How do I store details securely with django?


Hi Eric,


Thanks for the response.


This idea has an end goal of being deployed in a resilient way so most probably 
docker with some form of orchestration, Docker swarm or Kubernetes.


The credentials are mainly stored in a .env file at the moment and could be 
added to the secrets but I need for people who are admins for a particular 
cloud to add their cloud details to the app and then store their credentials 
securely.


Unfortunately this will need a dynamic storage mechanism which i don't know how 
to do yet


Regards


Lance



On 11/12/18 12:03 AM, PASCUAL Eric wrote:

Hi,


It can depend on which deployment option you plan to use for the application.


For instance, a Docker deployment orchestrated by Kubernetes gives the option 
of using secrets for sensitive information, which a hoster such as GCP manages 
conveniently. In this kind of deployment, configuration (and secrets) are 
passed to the app as environment variables, on which Kubernetes configuration 
maps and secrets are mapped to. Thanks to this, values are stored nowhere in 
the app code, companion files or database.


Regards


Eric


From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
<mailto:django-users@googlegroups.com> on behalf 
of Mike Dewhirst <mailto:mi...@dewhirst.com.au>
Sent: Sunday, November 11, 2018 11:07:14 PM
To: django-users@googlegroups.com<mailto:django-users@googlegroups.com>
Subject: Re: How do I store details securely with django?

On 12/11/2018 12:47 AM, Lance Haig wrote:
> Hi,
>
> I have a project I am working on https://github.com/lhaig/usery/ and
> part of the roadmap of the project is to add more cloud types to the
> list.
>
> I wanted to allow admins for these services to login and create
> records for their different clouds in the DB and t

Re: How do I store details securely with django?

2018-11-12 Thread PASCUAL Eric
Hi Lance,


 but I need for people who are admins for a particular cloud to add their cloud 
details to the app and then store their credentials securely.


I'm not sure to understand the need for adding cloud details to the app for the 
admins.


The suggestion I made assumed that sensitive information is managed as K8S 
secrets. As long as the admins have GCloud (for instance) credentials set 
(which are stored and managed at GCloud level), they can administrate the 
secrets resources by "applying" the corresponding YAML descriptors remotely 
from their workstation. The sensitive values are thus stored nowhere inside the 
application itself, but passed to the containers at runtime as environment 
variables.


Maybe I've misunderstood your need and sorry in this case if my answer is off 
topic.


Best


Eric


From: django-users@googlegroups.com  on behalf 
of Lance Haig 
Sent: Monday, November 12, 2018 9:07:30 AM
To: django-users@googlegroups.com
Subject: Re: How do I store details securely with django?


Hi Eric,


Thanks for the response.


This idea has an end goal of being deployed in a resilient way so most probably 
docker with some form of orchestration, Docker swarm or Kubernetes.


The credentials are mainly stored in a .env file at the moment and could be 
added to the secrets but I need for people who are admins for a particular 
cloud to add their cloud details to the app and then store their credentials 
securely.


Unfortunately this will need a dynamic storage mechanism which i don't know how 
to do yet


Regards


Lance



On 11/12/18 12:03 AM, PASCUAL Eric wrote:

Hi,


It can depend on which deployment option you plan to use for the application.


For instance, a Docker deployment orchestrated by Kubernetes gives the option 
of using secrets for sensitive information, which a hoster such as GCP manages 
conveniently. In this kind of deployment, configuration (and secrets) are 
passed to the app as environment variables, on which Kubernetes configuration 
maps and secrets are mapped to. Thanks to this, values are stored nowhere in 
the app code, companion files or database.


Regards


Eric


From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
<mailto:django-users@googlegroups.com> on behalf 
of Mike Dewhirst <mailto:mi...@dewhirst.com.au>
Sent: Sunday, November 11, 2018 11:07:14 PM
To: django-users@googlegroups.com<mailto:django-users@googlegroups.com>
Subject: Re: How do I store details securely with django?

On 12/11/2018 12:47 AM, Lance Haig wrote:
> Hi,
>
> I have a project I am working on https://github.com/lhaig/usery/ and
> part of the roadmap of the project is to add more cloud types to the
> list.
>
> I wanted to allow admins for these services to login and create
> records for their different clouds in the DB and then use these when
> people request access to these services.
>
> I need to find a secure way to store these credentials so that even if
> the DB is compromised that the credentials are safe.

I agree credentials should not be stored in the database but what are
your other assumptions about the threats?

How many sets of credentials will there be?

In future, will you be using simple credentials or tokens, certificates,
multi factor auth?

If this is a prototype and only a few sets are involved you can store
credentials in a file or one file per set and write a method to fetch
them as required. That will keep them out of the database and let you
rejig the method after you have decided how it should really work.

>
> Does anyone have suggestions on how I can accomplish this?
>
> I would really appreciate some advice.
>
> Regards
>
> Lance
>
>
>

--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/c8819341-7c60-56ee-6298-3a6a7897e9b1%40dewhirst.com.au.
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/dja

Re: hi everyone

2018-11-12 Thread PASCUAL Eric
Hi,


I didn't understand the explanation you gave about the reference to "real time" 
 in the context of your project. Please, have a look at this page for instance 
(https://en.wikipedia.org/wiki/Real-time_computing) to understand what "real 
time" means in computing.

With respect to having a complete Django project as an example for learning, 
the "poll" application used in the series of tutorials which are part of the 
official documentation should answer your expectation. Did you study this 
tutorials ? Almost (if not all) Django users have started their learning 
journey there. Have also a look at Django girls web site 
(https://djangogirls.org/). Don't be fooled by its name, this site is one of 
the best places to stop at when it comes to find serious help about Django.

Best


Eric


From: django-users@googlegroups.com  on behalf 
of akash kandpal <9654263057akashkand...@gmail.com>
Sent: Monday, November 12, 2018 7:56:16 AM
To: django-users@googlegroups.com
Subject: Re: hi everyone

I mean we can see some working projects and learn from it by implementing them 
ourselves and thus it will be more of a learning opportunity for us.


Regards,
Akash Kandpal.

On Mon, Nov 12, 2018, 12:22 PM Joel mailto:j...@eyrie.in> wrote:
I don't really understand what you mean. How can you put something on your 
resume when you haven't contributed to it?

On Mon, 12 Nov, 2018, 12:06 PM ramakurthy swamy 
mailto:veeraswam...@gmail.com> wrote:
hi sir thank u for giving reply and the real time means what the present 
projects are going on company based on python and django,,,
And i have a two years gap in my academic period based on that project i want 
to fill-up that gap so plz kindly help

On Sun, Nov 11, 2018 at 7:45 PM PASCUAL Eric 
mailto:eric.pasc...@cstb.fr>> wrote:

Hi,


What do you mean exactly by "real time" ? Can you describe the project you are 
thinking about ?


"Real time" relates to a very specific class of software, which one of the 
characteristics is to react to external events in a (most often) short and, 
deterministic time. For sure, neither Python nor Django fulfill the involved 
technical requirements, especially considering the deterministic property which 
is one of the RT non negotiable aspect.


BTW can you elaborate a bit on what you mean by "i want to keep that project in 
my resume" ?


Regards


Eric


From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
mailto:django-users@googlegroups.com>> on behalf 
of ramakurthy swamy mailto:veeraswam...@gmail.com>>
Sent: Sunday, November 11, 2018 2:29:51 PM
To: Django users
Subject: hi everyone

i am looking for real time project based on python and django plz help `me and 
i want to keep that project in my resume plz help me guiess


--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/f7b6adcd-4d1a-4f3a-abc7-b659be3c842c%40googlegroups.com<https://groups.google.com/d/msgid/django-users/f7b6adcd-4d1a-4f3a-abc7-b659be3c842c%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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/VI1P193MB04326D4B9AAA3A7EA2A856348CC00%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM<https://groups.google.com/d/msgid/django-users/VI1P193MB04326D4B9AAA3A7EA2A856348CC00%40VI1P193MB0432.EURP193.PROD.OUTLOOK.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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django

Re: solve problem to load template

2018-11-12 Thread PASCUAL Eric
Hi,


Is the directory where your template file resides included in the list of paths 
configured in the settings of your application ?


Regards


Eric


From: django-users@googlegroups.com  on behalf 
of Mohammad Shareef M 
Sent: Monday, November 12, 2018 6:48:14 AM
To: django-users@googlegroups.com
Subject: solve problem to load template


template = get_template('reports_base.html')

{TemplateDoesNotExist}common_email_templates/partial_display_marketing_msg.html

Pls help to solve this problem
Thanks & Regards,
Mahammad Shareef M
[https://docs.google.com/uc?export=download&id=1wRZggGgvC7aSRZr21VAUfps9COVQmgOo&revid=0Bzqees_1E8QUYzBxS0c5MUhwMGlnQlhTZitBKyszY2hKbDE0PQ]
 +919741482617
[https://docs.google.com/uc?export=download&id=1JLoMU48d8YKWmpuk2AEeyEq8yU4fSYMB&revid=0Bzqees_1E8QUSDhiY1RueldsUi9STlNiTmxqV1JQUVlDZk9NPQ]
 +971501340618
[https://docs.google.com/uc?export=download&id=1JLoMU48d8YKWmpuk2AEeyEq8yU4fSYMB&revid=0Bzqees_1E8QUSDhiY1RueldsUi9STlNiTmxqV1JQUVlDZk9NPQ]
 +971581756035

--
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/CAPUAdBEceLjivAqq0_3SUGFBMj5kFdqU52UCrZYO_1UA3MQt%3Dw%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/VI1P193MB043206106A26140AE3803A0F8CC10%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: How do I store details securely with django?

2018-11-11 Thread PASCUAL Eric
Hi,


It can depend on which deployment option you plan to use for the application.


For instance, a Docker deployment orchestrated by Kubernetes gives the option 
of using secrets for sensitive information, which a hoster such as GCP manages 
conveniently. In this kind of deployment, configuration (and secrets) are 
passed to the app as environment variables, on which Kubernetes configuration 
maps and secrets are mapped to. Thanks to this, values are stored nowhere in 
the app code, companion files or database.


Regards


Eric


From: django-users@googlegroups.com  on behalf 
of Mike Dewhirst 
Sent: Sunday, November 11, 2018 11:07:14 PM
To: django-users@googlegroups.com
Subject: Re: How do I store details securely with django?

On 12/11/2018 12:47 AM, Lance Haig wrote:
> Hi,
>
> I have a project I am working on https://github.com/lhaig/usery/ and
> part of the roadmap of the project is to add more cloud types to the
> list.
>
> I wanted to allow admins for these services to login and create
> records for their different clouds in the DB and then use these when
> people request access to these services.
>
> I need to find a secure way to store these credentials so that even if
> the DB is compromised that the credentials are safe.

I agree credentials should not be stored in the database but what are
your other assumptions about the threats?

How many sets of credentials will there be?

In future, will you be using simple credentials or tokens, certificates,
multi factor auth?

If this is a prototype and only a few sets are involved you can store
credentials in a file or one file per set and write a method to fetch
them as required. That will keep them out of the database and let you
rejig the method after you have decided how it should really work.

>
> Does anyone have suggestions on how I can accomplish this?
>
> I would really appreciate some advice.
>
> Regards
>
> Lance
>
>
>

--
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/c8819341-7c60-56ee-6298-3a6a7897e9b1%40dewhirst.com.au.
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/VI1P193MB043243D0747282C2D96F60E38CC00%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: hi everyone

2018-11-11 Thread PASCUAL Eric
Hi,


What do you mean exactly by "real time" ? Can you describe the project you are 
thinking about ?


"Real time" relates to a very specific class of software, which one of the 
characteristics is to react to external events in a (most often) short and, 
deterministic time. For sure, neither Python nor Django fulfill the involved 
technical requirements, especially considering the deterministic property which 
is one of the RT non negotiable aspect.


BTW can you elaborate a bit on what you mean by "i want to keep that project in 
my resume" ?


Regards


Eric


From: django-users@googlegroups.com  on behalf 
of ramakurthy swamy 
Sent: Sunday, November 11, 2018 2:29:51 PM
To: Django users
Subject: hi everyone

i am looking for real time project based on python and django plz help `me and 
i want to keep that project in my resume plz help me guiess


--
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/f7b6adcd-4d1a-4f3a-abc7-b659be3c842c%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/VI1P193MB04326D4B9AAA3A7EA2A856348CC00%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Create rest service

2018-11-05 Thread PASCUAL Eric
Hi,


Have a look at the "migrate.py inspectdb" command documentation 
(https://docs.djangoproject.com/fr/2.1/ref/django-admin/#inspectdb).


This command generates the models for tables in an existing DB. To avoid 
messing with the existing data, these models are declared as non managed, which 
means that the tables are not created  nor modified by the migration process.


It should give you a good starting point.


Regards


Eric

django-admin et manage.py | Django documentation | 
Django
docs.djangoproject.com
Obtention d’aide¶ django-admin help¶. Lancez django-admin help pour afficher 
des informations d’utilisation et une liste des commandes fournies par chaque 
application.. Lancez django-admin help--commands pour afficher une liste des 
commandes disponibles.. Lancez django-admin help  pour afficher une 
description de la commande concernée et une liste de ses options disponibles.


From: django-users@googlegroups.com  on behalf 
of soumyajit banerjee 
Sent: Monday, November 5, 2018 12:55:42 PM
To: Django users
Subject: Create rest service

I have a one database (postgre). Same database currently using by one java 
application another one is php. But I want to create rest services through 
python django. Could you please guide me how to start. Actually I'm confused 
model creation, it's needed to create model or we can write direct sql query 
through view function. Please suggest me.

Regards,
Soumyajit

--
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/f37e28be-a09b-4988-a97c-015dc477e0e2%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/VI1P193MB0432621B6E7A0DF01CE89ADD8CCA0%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Using django on kubernetes

2018-11-02 Thread PASCUAL Eric
My opinion is that Minikube is the easiest way, since it is quite simple to set 
up and run. Behind the curtains it uses a VirtualBox machine BTW if I'm not 
mistaken (at least under Linux).


You can of course set up a multi-node stack using several VMs (after all, this 
is exactly what hosters do) but I'm afraid you'll fight a lot before having it 
run properly.


If you have access to GCP resources, you can go for it of course. But you'll 
have to master a couple of GCP specific topics in addition to Kubernetes ones.


So the bottom line if I were you : start learning by practising with Minikube, 
and when you'll get used to K8S concepts and YAML descriptors, move a step 
forward with GCP for instance if you need to.


Regards


Eric


From: django-users@googlegroups.com  on behalf 
of Dan Davis 
Sent: Thursday, November 1, 2018 9:14:36 PM
To: Django users
Subject: Re: Using django on kubernetes

Thanks, would you say that running Minikube is the best way to learn Kubernetes 
at a significant level, or would you recommend a small Virtualbox/vagrant setup 
that really is a multi-node Kubernetes?   I don't really have enough cores and 
memory for the later anyway, but I could just start-up workloads on Amazon KCS 
or GCP to learn, if Minikube is not enough.

On Tuesday, October 30, 2018 at 5:59:18 PM UTC-4, Eric Pascual wrote:

I'm not even sure those are the same as Docker containers even though 
Kubernetes can run Docker images.


Kubernetes is an orchestrator for Docker containers, not a container engine. 
You can run the same images in K8S managed containers or on your local Docker 
engine, using docker-compose for instance. I currently work on a project 
related to a services platform based on micro-services deployed in Docker 
containers. I test the images locally on my machine either in docker-compose 
assemblies or in Minikube (for validating the K8S descriptors involved in 
deployment, configuration,...) and then I deploy the stuff on GCP.


As already mentioned, K8S provides tools (indicators, graphs,...) to monitor 
the resources used by pods. I would not use Linux metrics, if ever they were 
representative when collected from inside a pod, since the containers are 
running on VMs and they can be spread over different nodes if your 
configuration involves multi-nodes load balancing.


Eric


From: django...@googlegroups.com  on behalf of Dan 
Davis 
Sent: Tuesday, October 30, 2018 6:56:32 PM
To: Django users
Subject: Re: Using django on kubernetes

Andreas,

I don't know terribly much about Kubernetes, only Docker, however it seems that 
Kubernetes must natively provide some metrics collection, i.e 
https://kubernetes.io/docs/tasks/debug-application-cluster/resource-usage-monitoring/.
   It would be nice to correlate particular views and their arguments with 
resource use.   If you are using a process model, not a threading model, then I 
think the Linux system call getrusage() could do that, providing that it is 
supported in Kubernetes containers.I'm not even sure those are the same as 
Docker containers even though Kubernetes can run Docker images.  Maybe you can 
educate me!

Anyway, the package django-statsd might provide some help collecting APM data 
without something like NewRelic, but if you can use a real APM, do it.

On Tuesday, October 30, 2018 at 4:28:29 AM UTC-4, Andréas Kühne wrote:
Hi all,

I have created a SPA with angular on the frontend and django rest framework on 
the backend. It also has celery to do background tasks. Everything is working 
as intended and it is running pretty smoothly.

We have deployed it on kubernetes - so the frontend (with nginx) is running in 
one pod, the backend is running in another and celery is running on a third. 
Everything is connected and works. My question is more about the resources 
settings for django. Does anyone have any experience in setting up this? 
Currently I am running without resource limitations - which means that the 
kubernetes master doesn't know how much resources the django pod needs.

There has to be someone more who has done this and has setup the resource 
limits correctly - I would like some inspiration. I don't know how much django 
requires

Andréas

--
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 djang...@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/f9691131-cb97-4286-a248-73aa65750efb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received

Re: Running a custom code after the server is up

2018-11-02 Thread PASCUAL Eric
Hi,


IMHO the simplest way is to use cron.


Since you are working with Docker, one option is to add a container to your 
stack, sharing the same image as your Django app so that it can run the 
management command implementing your periodic process. Configure this container 
so that the command it runs is the cron daemon, and of course schedule your 
periodic task in the crontab.


Some people use Gunicorn start hook to fork a sub-process running the cron 
daemon. Others embed supervisor in a container and manage the web app process 
and the other ones with it. Although it works,  such approaches go against the 
rule which says that a Docker container should handle only one thing (either 
the app server or the cron stuff in you case) so that it can be managed 
independantly (scale, update image, restart...).


This is important when you deploy your stack under the control of an 
orchestrator such as Kubernetes, which will manage the containers (err. the 
"pods") automatically so that the state or the stack is the targeted one WRT 
replicas count, resource limits...


Hope this helps.


Eric


From: django-users@googlegroups.com  on behalf 
of Bartosz Gańcza 
Sent: Friday, November 2, 2018 3:31:38 PM
To: django-users@googlegroups.com
Subject: Running a custom code after the server is up

Hi everyone!

I am somewhat of a Django beginner and I can't seem to find an easy solution to 
what I need to do anywhere.

I have a web scraping code I wish to run in the background automatically (once) 
after the server is up and running. I use Docker to fire up the DB and the web 
server itself but can't seem to be able to configure it to also fire up the 
management command I configured that runs the scraping code (I guess using 
Docker for that is either beyond my current knowledge or is just not possible 
without using specialised tools like cron, which I don't fully understand).

Is there any way to do something like this in Django itself, without resorting 
to "ready" function? (I did that at first but it stops the server from running 
until the code completes and also runs it at least twice)

Best,
Bartosz

--
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/CAOjbnAWtCMWRck45hgZQqeaY-U86iEmiGs%2Btpq617V81_%2B6hkQ%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/VI1P193MB04324F801770E468502CBEC98CCF0%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Using django on kubernetes

2018-10-30 Thread PASCUAL Eric
I'm not even sure those are the same as Docker containers even though 
Kubernetes can run Docker images.


Kubernetes is an orchestrator for Docker containers, not a container engine. 
You can run the same images in K8S managed containers or on your local Docker 
engine, using docker-compose for instance. I currently work on a project 
related to a services platform based on micro-services deployed in Docker 
containers. I test the images locally on my machine either in docker-compose 
assemblies or in Minikube (for validating the K8S descriptors involved in 
deployment, configuration,...) and then I deploy the stuff on GCP.


As already mentioned, K8S provides tools (indicators, graphs,...) to monitor 
the resources used by pods. I would not use Linux metrics, if ever they were 
representative when collected from inside a pod, since the containers are 
running on VMs and they can be spread over different nodes if your 
configuration involves multi-nodes load balancing.


Eric


From: django-users@googlegroups.com  on behalf 
of Dan Davis 
Sent: Tuesday, October 30, 2018 6:56:32 PM
To: Django users
Subject: Re: Using django on kubernetes

Andreas,

I don't know terribly much about Kubernetes, only Docker, however it seems that 
Kubernetes must natively provide some metrics collection, i.e 
https://kubernetes.io/docs/tasks/debug-application-cluster/resource-usage-monitoring/.
   It would be nice to correlate particular views and their arguments with 
resource use.   If you are using a process model, not a threading model, then I 
think the Linux system call getrusage() could do that, providing that it is 
supported in Kubernetes containers.I'm not even sure those are the same as 
Docker containers even though Kubernetes can run Docker images.  Maybe you can 
educate me!

Anyway, the package django-statsd might provide some help collecting APM data 
without something like NewRelic, but if you can use a real APM, do it.

On Tuesday, October 30, 2018 at 4:28:29 AM UTC-4, Andréas Kühne wrote:
Hi all,

I have created a SPA with angular on the frontend and django rest framework on 
the backend. It also has celery to do background tasks. Everything is working 
as intended and it is running pretty smoothly.

We have deployed it on kubernetes - so the frontend (with nginx) is running in 
one pod, the backend is running in another and celery is running on a third. 
Everything is connected and works. My question is more about the resources 
settings for django. Does anyone have any experience in setting up this? 
Currently I am running without resource limitations - which means that the 
kubernetes master doesn't know how much resources the django pod needs.

There has to be someone more who has done this and has setup the resource 
limits correctly - I would like some inspiration. I don't know how much django 
requires

Andréas

--
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/f9691131-cb97-4286-a248-73aa65750efb%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/VI1P193MB043254CFEF56E31BCFE1124C8CCC0%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Using django on kubernetes

2018-10-30 Thread PASCUAL Eric
but I am a bit afraid that the memory usage for example might change over time?


It will of course, but apart if you have some memory leak somewhere, it will 
tend to stabilize over time.


Ah well - I will have to monitor this for an extended period of time and see 
what happens then :-)


For sure. I can't see any other way to have a realistic assessment otherwise.


Once you'll get some figures, you can elaborate the limits by adding a bit of 
headroom (let's say 20% more for instance). You can reduce this amount if you 
are short, or if you observe that the situation is rather stable, but in this 
case there's a risk for K8S to kill and restart your pods too often. In any 
case, it's a matter of compromises.


Regards


Eric


From: django-users@googlegroups.com  on behalf 
of Andréas Kühne 
Sent: Tuesday, October 30, 2018 1:25:11 PM
To: django-users@googlegroups.com
Subject: Re: Using django on kubernetes

Thanks for the replys,

I am of course monitoring the resources - but I am a bit afraid that the memory 
usage for example might change over time? Ah well - I will have to monitor this 
for an extended period of time and see what happens then :-)

Regards,

Andréas


Den tis 30 okt. 2018 kl 12:17 skrev Jason 
mailto:jjohns98...@gmail.com>>:
using infrastructure monitoring such as new relic can lend valuable insight 
into what resources pods are using vs their default allocation

--
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/7972f667-e1a6-4115-b75c-2e8656e256c3%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/CAK4qSCcwq8ca6VDO0coxQjES9%2BOjEyt%2BKSQmJD5e231gocvRgA%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/VI1P193MB04326CEE8E9089F61D7CE3B78CCC0%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Using django on kubernetes

2018-10-30 Thread PASCUAL Eric
Hi,


Django is not really the key factor here, and the amount of consumed resources 
depends mainly on what your business logic does on top of Django.


IMHO the only way to properly estimate the limits is observing the metrics and 
trends of the related pods for a significant period and with an application 
load representative of the operational conditions. You'll have then rough 
estimates of how much RAM, CPU,... is used by the pods, and be able to set the 
limits correctly.


Maybe not question was not exactly this.


Eric


From: django-users@googlegroups.com  on behalf 
of Andréas Kühne 
Sent: Tuesday, October 30, 2018 9:27:35 AM
To: django-users@googlegroups.com
Subject: Using django on kubernetes

Hi all,

I have created a SPA with angular on the frontend and django rest framework on 
the backend. It also has celery to do background tasks. Everything is working 
as intended and it is running pretty smoothly.

We have deployed it on kubernetes - so the frontend (with nginx) is running in 
one pod, the backend is running in another and celery is running on a third. 
Everything is connected and works. My question is more about the resources 
settings for django. Does anyone have any experience in setting up this? 
Currently I am running without resource limitations - which means that the 
kubernetes master doesn't know how much resources the django pod needs.

There has to be someone more who has done this and has setup the resource 
limits correctly - I would like some inspiration. I don't know how much django 
requires

Andréas

--
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/CAK4qSCf2d5fkhcG_g6oy_PY7yLcLtsV8fSsc%3D%2BFFOfdmGrkThA%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/VI1P193MB0432F2561C43E449C47EC1D08CCC0%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Django to serve JSON: overkill?

2018-10-28 Thread PASCUAL Eric
Hi Charley,


You should not regret this choice.

Sometimes Django seems a bit overkill at the first glance. But most of the 
times, once the project has made some progress you'll quickly appreciate the 
fact it is like Python : batteries included. No need to hunt for external 
add-ons which will integrate more or less easily when it comes to take care of 
CORS, CSRF, sessions, I18N,... All is already here for free. I could verify 
this on a Flask based project : you're left alone when time comes for you to 
find the right LEGO blocks and make then fit together. Django creators have 
already made this for you, and they're very smart people.


And of course the default Django configuration can be optimized by removing 
middlewares and features you don't need to cut it down to the strict necessary. 
So, why bother ?


Regards


Eric


From: django-users@googlegroups.com  on behalf 
of Charley Paulus 
Sent: Sunday, October 28, 2018 2:53:04 PM
To: Django users
Subject: Re: Django to serve JSON: overkill?

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.

-- 
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/VI1P193MB04325B2D1B8CF0A98E5C3C2A8CF20%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Should I use Django-Rest-Framework for performance reasons, despite not needing an externally-consumable API?

2018-10-28 Thread PASCUAL Eric
Hi,


Do you think there's any reason to use DRF despite not needing an 
externally-consumable API?

None that I can think about. But I don't pretend to be an expert on the topic ;)


IMHO it is just a matter of planing for the future. If you are certain that 
nothing else but your current app will need to play with the models, adding a 
REST API (be it written on top of DRF or not) is not required at all. To my 
knowledge it will not bring any benefit WRT performances. Chances are that it 
will be the opposite (but not in dramatic proportions however if the underlying 
stack is properly chosen and configured) since the REST API adds a layer of 
HTTP based exchanges.


Regards


Eric


From: django-users@googlegroups.com  on behalf 
of Tyler Lynch 
Sent: Saturday, October 27, 2018 7:12:13 PM
To: Django users
Subject: Re: Should I use Django-Rest-Framework for performance reasons, 
despite not needing an externally-consumable API?

Hey Eric, thanks for getting back to me again!

As I don't want to have an externally-consumable API for this application 
(would be more of a liability than asset for me right now), I am most likely 
going to not use DRF.

I know it'll be more time-consuming refactoring if I ever do decide to use DRF, 
but I'm okay deferring this decision for now.

Do you think there's any reason to use DRF despite not needing an 
externally-consumable API? Would using an internally-consumed API have 
different benefits? It seems the consensus is that adding DRF is more likely to 
limit performance than enhance, as you suggested earlier.

Regards,
Tyler


On Friday, 26 October 2018 18:02:43 UTC-4, Eric Pascual wrote:

Hi,


You mention that adding DRF can actually make you lose some potential benefits 
from caching?


Django does a lot of job WRT caching data at the ORM level and there is a 
"direct path" from the UI and the ORM. I've the feeling that putting a REST API 
in the middle have chances to defeat some of the involved strategies.


I guess DRF can be added to the project at any time


Yes of course, but the views of the UI layer will have to be reworked. When 
dealing directly with the ORM, they use query sets. When the REST API is added, 
you'll have to deal with serializers instead. The migration will represent some 
work.


So if you think that there are 80% of chances the application will evolve to a 
REST API based architecture in a not too distant future, my advice would be 
introduced it from the begining.


But once again, this is a matter of appreciation.


Best


Eric PASCUAL

Centre Scientifique et Technique du Bâtiment
290 route des Lucioles - BP 209
06904 SOPHIA ANTIPOLIS CEDEX
http://www.cstb.fr


From: django...@googlegroups.com  on behalf of 
Tyler Lynch 
Sent: Friday, October 26, 2018 4:18:49 PM
To: Django users
Subject: Re: Should I use Django-Rest-Framework for performance reasons, 
despite not needing an externally-consumable API?

Hi Eric,

Thanks for the response

You mention that adding DRF can actually make you lose some potential benefits 
from caching? Might i ask how that is so? I actually thought it was supposed to 
be the opposite (shows you what I know tho hah)

I guess DRF can be added to the project at any time tho, so there's no need to 
build the project with DRF built-in from beginning. So if I do need it down the 
road, it won't be difficult to add it in.


On Friday, 26 October 2018 04:28:23 UTC-4, Eric Pascual wrote:

Hi,


Using DRF can help when there is a need for decoupling the presentation layer 
from the logic one, for instance if the logic is planned to be used in other 
scenarios that the interactive Web app.


One can argue that structuring the logic as a Python package can do it, but 
this will not work if the deployment involves splitting front-end and logic 
back-end in distinct nodes (f.i. in a Docker multi-container based deployment).


Introducing DRF adds for sure a level of complexity and you'll loose some 
potential caching benefits, but it lets the path opened if ever the above 
mentioned evolution of the application appears in the future. You will not have 
to refactor anything then.


The bottom line is that there is no absolute answer to the question. It depends 
on what can be the plans for the application evolutions in the future.


Regards


Eric


From: django...@googlegroups.com  on behalf of 
Andréas Kühne 
Sent: Friday, October 26, 2018 9:29:40 AM
To: django...@googlegroups.com
Subject: Re: Should I use Django-Rest-Framework for performance reasons, 
despite not needing an externally-consumable API?

Hi,

I really don't get why you would want to do that? If you are doing only a 
"standard" website - you don't want or NEED the extra complexity of running 
DRF. It's not that DRF is hard to setup - but for example if you want to 
present a list of items - in "standard" django, you create the list and add it 

Re: Django to serve JSON: overkill?

2018-10-28 Thread PASCUAL Eric
Hi,


If the JSON is related to a data model, and if this model is elaborated and 
subject to evolution in the furure, Django can help a lot. Add Django 
RESTFramework to the combo to take care of the REST stuff.


If not, I'd suggest Falcon (https://falconframework.org/), which is a light and 
very efficient framework made for developing REST based services. I've used it 
quite a lot for writing micro-services of a complex platform. Services working 
with data models are developed on top of Django. The other ones are Falcon 
based.

Falcon - Bare-metal web API framework for Python
falconframework.org
Extended Test. Falcon was also benchmarked under CPython 3.6 with a more 
realistic scenario, in which the routing table had multiple entries, the query 
string contained percent-encoded characters, and several complex response 
headers were set in the response.

Hope this helps


Eric


From: django-users@googlegroups.com  on behalf 
of Charley Paulus 
Sent: Saturday, October 27, 2018 3:13:33 PM
To: Django users
Subject: Django to serve JSON: overkill?

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.

-- 
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/VI1P193MB04326D9BB6EB175F38C29FD58CF20%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Should I use Django-Rest-Framework for performance reasons, despite not needing an externally-consumable API?

2018-10-26 Thread PASCUAL Eric
Hi,


You mention that adding DRF can actually make you lose some potential benefits 
from caching?


Django does a lot of job WRT caching data at the ORM level and there is a 
"direct path" from the UI and the ORM. I've the feeling that putting a REST API 
in the middle have chances to defeat some of the involved strategies.


I guess DRF can be added to the project at any time


Yes of course, but the views of the UI layer will have to be reworked. When 
dealing directly with the ORM, they use query sets. When the REST API is added, 
you'll have to deal with serializers instead. The migration will represent some 
work.


So if you think that there are 80% of chances the application will evolve to a 
REST API based architecture in a not too distant future, my advice would be 
introduced it from the begining.


But once again, this is a matter of appreciation.


Best


Eric PASCUAL

Centre Scientifique et Technique du Bâtiment
290 route des Lucioles - BP 209
06904 SOPHIA ANTIPOLIS CEDEX
http://www.cstb.fr


From: django-users@googlegroups.com  on behalf 
of Tyler Lynch 
Sent: Friday, October 26, 2018 4:18:49 PM
To: Django users
Subject: Re: Should I use Django-Rest-Framework for performance reasons, 
despite not needing an externally-consumable API?

Hi Eric,

Thanks for the response

You mention that adding DRF can actually make you lose some potential benefits 
from caching? Might i ask how that is so? I actually thought it was supposed to 
be the opposite (shows you what I know tho hah)

I guess DRF can be added to the project at any time tho, so there's no need to 
build the project with DRF built-in from beginning. So if I do need it down the 
road, it won't be difficult to add it in.


On Friday, 26 October 2018 04:28:23 UTC-4, Eric Pascual wrote:

Hi,


Using DRF can help when there is a need for decoupling the presentation layer 
from the logic one, for instance if the logic is planned to be used in other 
scenarios that the interactive Web app.


One can argue that structuring the logic as a Python package can do it, but 
this will not work if the deployment involves splitting front-end and logic 
back-end in distinct nodes (f.i. in a Docker multi-container based deployment).


Introducing DRF adds for sure a level of complexity and you'll loose some 
potential caching benefits, but it lets the path opened if ever the above 
mentioned evolution of the application appears in the future. You will not have 
to refactor anything then.


The bottom line is that there is no absolute answer to the question. It depends 
on what can be the plans for the application evolutions in the future.


Regards


Eric


From: django...@googlegroups.com  on behalf of 
Andréas Kühne 
Sent: Friday, October 26, 2018 9:29:40 AM
To: django...@googlegroups.com
Subject: Re: Should I use Django-Rest-Framework for performance reasons, 
despite not needing an externally-consumable API?

Hi,

I really don't get why you would want to do that? If you are doing only a 
"standard" website - you don't want or NEED the extra complexity of running 
DRF. It's not that DRF is hard to setup - but for example if you want to 
present a list of items - in "standard" django, you create the list and add it 
to the context data. In DRF - you need to create the list, serialize it into 
json (or xml if you want to go that route), on the frontend you then need to 
deserialize the list and present it.

You add a lot of complexity and need to write a lot of frontend code.

Working with "standard" django - you can cache a lot of things in different 
places. You can for example cache an entire response with template, or just 
cache the database calls and present them in a template. This is not hard to 
cache or to setup.

I think I would need to know more about your use case to understand it better 
:-)

Regards,

Andréas


Den fre 26 okt. 2018 kl 03:44 skrev Tyler Lynch :
I have no need for an externally consumable API, but I am interested in using 
Django-Rest-Framework simply for performance reasons.

I'm led to believe that by decoupling my front and back end and then simply 
consuming the DRF api within views, that I can setup a better caching system? 
Does this make sense? Using DRF from an architectural standpoint (with the goal 
of optimizing caching & performance) despite not needing an externally used 
API? Or am I totally off base and confused? Any advice would be 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...@googlegroups.com.
To post to this group, send email to djang...@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/8b55ff9a-e915-4546-bf3c-1b20a25e4826%40google

Re: Should I use Django-Rest-Framework for performance reasons, despite not needing an externally-consumable API?

2018-10-26 Thread PASCUAL Eric
Hi,


Using DRF can help when there is a need for decoupling the presentation layer 
from the logic one, for instance if the logic is planned to be used in other 
scenarios that the interactive Web app.


One can argue that structuring the logic as a Python package can do it, but 
this will not work if the deployment involves splitting front-end and logic 
back-end in distinct nodes (f.i. in a Docker multi-container based deployment).


Introducing DRF adds for sure a level of complexity and you'll loose some 
potential caching benefits, but it lets the path opened if ever the above 
mentioned evolution of the application appears in the future. You will not have 
to refactor anything then.


The bottom line is that there is no absolute answer to the question. It depends 
on what can be the plans for the application evolutions in the future.


Regards


Eric


From: django-users@googlegroups.com  on behalf 
of Andréas Kühne 
Sent: Friday, October 26, 2018 9:29:40 AM
To: django-users@googlegroups.com
Subject: Re: Should I use Django-Rest-Framework for performance reasons, 
despite not needing an externally-consumable API?

Hi,

I really don't get why you would want to do that? If you are doing only a 
"standard" website - you don't want or NEED the extra complexity of running 
DRF. It's not that DRF is hard to setup - but for example if you want to 
present a list of items - in "standard" django, you create the list and add it 
to the context data. In DRF - you need to create the list, serialize it into 
json (or xml if you want to go that route), on the frontend you then need to 
deserialize the list and present it.

You add a lot of complexity and need to write a lot of frontend code.

Working with "standard" django - you can cache a lot of things in different 
places. You can for example cache an entire response with template, or just 
cache the database calls and present them in a template. This is not hard to 
cache or to setup.

I think I would need to know more about your use case to understand it better 
:-)

Regards,

Andréas


Den fre 26 okt. 2018 kl 03:44 skrev Tyler Lynch 
mailto:tyleraly...@gmail.com>>:
I have no need for an externally consumable API, but I am interested in using 
Django-Rest-Framework simply for performance reasons.

I'm led to believe that by decoupling my front and back end and then simply 
consuming the DRF api within views, that I can setup a better caching system? 
Does this make sense? Using DRF from an architectural standpoint (with the goal 
of optimizing caching & performance) despite not needing an externally used 
API? Or am I totally off base and confused? Any advice would be 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/8b55ff9a-e915-4546-bf3c-1b20a25e4826%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/CAK4qSCeFqeGT8EbZFbWOGpHKY36D4bwvayLBxGm0YsBBFX6jnw%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/AM6P193MB0421AAC62D90081D00F7FF298CF00%40AM6P193MB0421.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: How to store images that was select in a form

2018-10-11 Thread PASCUAL Eric
Hi,


Did you study the documentation about the media and how to handle them ? It is 
quite explicit and if I remember well there are a couple of code examples.


Eric


From: django-users@googlegroups.com  on behalf 
of kheinrichdja...@gmail.com 
Sent: Thursday, October 11, 2018 11:24:55 AM
To: Django users
Subject: How to store images that was select in a form

Hi,


I have a problem about storing images
that I selected through a Form  into some random folder.

How can I do that?

Also I want to show this selected image on the website.

What should I do?


Here my code:


#Views.py
from django.shortcuts import render
from django.views.generic import TemplateView
from .forms import menuForm
from .models  import ImageMenu


class HomeView(TemplateView):

def get (self,request):
frm = menuForm()
ima = ImageMenu.objects.all()

return  render(request, 'base.html',   {'form':frm, 'im1' : ima})

def post(self, request):
image = menuForm(request.POST)
if image.is_valid():
form.save()
image = form.cleaned_data['im']
args = { 'image' : image}
return  render(request, 'base.html', args )



#urls.py
-
from django.urls import path
from ledapp.views import HomeView

urlpatterns = [
path('', HomeView.as_view(), name = 'home' ),

]
--

#settings.py
--
STATIC_URL = '/static/'


MEDIA_URL = '/content/'


MEDIA_ROOT =os.path.join(BASE_DIR,  'content' )
--


#forms.py

from django import forms

class  menuForm(forms.Form):
im = forms.ImageField(max_length = 20)




class mForms(forms.Form):
ims= forms.ImageField(max_length = 20)



#html-File




.grid-container {
  display: grid;
  grid-template-columns: auto auto auto auto auto auto;
  grid-gap: 10px;
  background-color: #2196F3;
  padding: 10px;
}


.grid-container .item6 {
  background-color: #2196F3;
  text-align: left;
  padding: 15px 0;
  font-size: 20px;
}


.grid-container .item7 {
  background-color: #2196F3;
  text-align: left;
  padding: 15px 0;
  font-size: 20px;
}
.grid-container > div {
  background-color: rgba(255, 255, 255, 0.8);
  text-align: center;
  padding: 20px 0;
  font-size: 20px;
}

.item2 {
  grid-area: 2 /1 / 2/ 1;
}
.item4 {
  grid-area: 2 /4 / 2/ 4;
}


.item6 {
  grid-area: 5 / 3 / 5 / 2;
}
.item7 {
  grid-area: 6 / 3 / 5 / 3
}

.item8 {
  grid-area: 1 / 2 / 5 / 2;
}
.item9 {
  grid-area: 1 / 3 / 5 / 3;
}








Menu


  Senden
  Aktivieren

  Helligkeit
  Bildwechselfrequenz

  
 Submit

  
  


{{image.pic.url}} 
  9















--
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/f6d7b970-8256-40ad-8b63-a5e266d416ca%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/VI1P193MB0432BACD6A8F00031C18DCA08CE10%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: What are packages or tool that are useful to make a Human resource management system

2018-10-09 Thread PASCUAL Eric
Well... it only depends on you and your skills, plus what you want your app to 
do exactly.


How do you want  people other than you answer such a question ?


Eric


From: django-users@googlegroups.com  on behalf 
of Md.iftequar iqbal 
Sent: Tuesday, October 9, 2018 5:13:21 AM
To: django-users@googlegroups.com
Subject: Re: What are packages or tool that are useful to make a Human resource 
management system

Thank you for reply

Cay you tell me how much time it will take to complete the hrm software


On Mon, 8 Oct 2018, 4:39 pm Rizwan Ahmed, 
mailto:rizahmed...@gmail.com>> wrote:
go throu this link it may help u.
http://awesome-django.com/

otherwise you can look at github.

On Mon, Oct 8, 2018 at 8:51 AM django_learner 
mailto:iftequa...@gmail.com>> wrote:
I am newbie to django. I am trying to make a Human resource management system 
software but it is very hard to make from scratch. Can anyone suggest any 
packages or tools that will be useful.

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 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/c19356f9-d0e0-43fd-902a-7d220b80c9c7%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/CAPjdRFEwgGZpHSMgirMZjyGPW_pjNDOXPF2PFDRpd8TwBZvj1Q%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/CAHAmP3RyemjpChWu%3DRcNjBi1M0GDEandvHq8Q4eNkvq7wQHOFw%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/VI1P193MB04322938B45B9B97F2B143358CE70%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: What are packages or tool that are useful to make a Human resource management system

2018-10-08 Thread PASCUAL Eric
Hi,


Just my $0.02, but human resources management is a quite broad topic, and the 
kind of project you're planning is not a toy (i.e. "Hello world" style) 
application :)


In addition, since you are a Django newbie, I'm afraid that it could be out of 
reach with your actual skills. It would thus be wiser to work with some 
experienced people and not to undertake such a project alone. This way, there 
will be far more chances to succeed. In addition you'll learn a lot from your 
buddies, and you'll be ready to fly solo for the next project of such an 
ambition.


Anyway, before thinking about coding, and no matter which language, framework 
or technology will be used, you should start by defining carefully which 
functionalities the system you plan to create will offer and the constraints it 
must fulfil (deployment, security, access rights management,...).


Once this step completed and the result reviewed and approved by people who 
will use and operate the system, you will have in hands the list of technical 
functionalities you need to use. Have then a look at the Django Packages 
Repository (https://djangopackages.org/), which is packed with hundreds (or 
maybe thousands) of apps covering a tremendously broad spectrum. I'm pretty 
sure you'll find there valuable building blocks implementing some of the 
features required, without having you to create them from scratch. Your global 
task will thus be reduced and you'll be able to focus on the remaining features 
and code them. BTW studying how people have implemented the packages you'll 
pick from DPR will teach you a lot about Django, and probably about Python and 
coding too.


Hope this will help.


Eric


From: django-users@googlegroups.com  on behalf 
of django_learner 
Sent: Monday, October 8, 2018 05:20
To: Django users
Subject: What are packages or tool that are useful to make a Human resource 
management system

I am newbie to django. I am trying to make a Human resource management system 
software but it is very hard to make from scratch. Can anyone suggest any 
packages or tools that will be useful.

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 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/c19356f9-d0e0-43fd-902a-7d220b80c9c7%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/AM6P193MB042172989B4C98CC91B19C418CE60%40AM6P193MB0421.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Can anyone share code for uploading csv or excel file to sqlite3 database.

2018-09-28 Thread PASCUAL Eric
Hi,


Which error(s) did you get exactly ? It is not clear in you message whether 
your problem is at the CSV data processing level or at the Django one.


In case this could help, using the standard csv module you can obtain a reader 
wich takes care of parsing and decoding thanks to the reader() module function. 
You pass it the file object directly, without reading its content in memory. 
Since it provides an iterator over the data, yielding rows one at a time as 
tuples, this lets you load big files without any problem.


The DictReader class of the same module works more or less the same way, but 
returns rows as dicts which keys are the CSV columns names, making the mapping 
code more readable and self-documented.


Best


Eric


From: django-users@googlegroups.com  on behalf 
of BBG 
Sent: Thursday, September 27, 2018 8:41:42 PM
To: Django users
Subject: Re: Can anyone share code for uploading csv or excel file to sqlite3 
database.

I have tried this but not working


def upload_csv(request):
data = {}
if "GET" == request.method:
return render(request, "add_student/bulk.html", data)
# if not GET, then proceed
try:
csv_file = request.FILES["csv_file"]
if not csv_file.name.endswith('.csv'):
messages.error(request,'File is not CSV type')
return HttpResponseRedirect(reverse("add_student:upload_csv"))
#if file is too large, return
if csv_file.multiple_chunks():
messages.error(request,"Uploaded file is too big (%.2f MB)." % 
(csv_file.size/(1000*1000),))
return HttpResponseRedirect(reverse("add_student:upload_csv"))

file_data = csv_file.read().decode("utf-8")

lines = file_data.split("\n")
#loop over the lines and save them in db. If error , store as string 
and then display
for line in lines:
fields = line.split(",")
data_dict = {}
data_dict["enrollment_no"] = fields[0]
data_dict["student_name"] = fields[1]
data_dict["gender"] = fields[2]
data_dict["course"] = fields[3]
data_dict["category"] = fields[4]
data_dict["admission_year"] = fields[5]
data_dict["branch"] = fields[6]
data_dict["current_semester"] = fields[7]
data_dict["address"] = fields[8]
data_dict["city"] = fields[9]
data_dict["district"] = fields[10]
data_dict["state"] = fields[11]
data_dict["student_contact"] = fields[12]
data_dict["parent_contact"] = fields[13]
try:
form = EventsForm(data_dict)
if form.is_valid():
form.save()
else:

logging.getLogger("error_logger").error(form.errors.as_json())
except Exception as e:
logging.getLogger("error_logger").error(repr(e))
pass
except Exception as e:
logging.getLogger("error_logger").error("Unable to upload file. 
"+repr(e))
messages.error(request,"Unable to upload file. "+repr(e))

return HttpResponseRedirect(reverse("add_student:upload_csv"))

On Thursday, September 27, 2018 at 1:59:24 PM UTC+5:30, Eric Pascual wrote:

Hi,


Have you studied the documentation of the CSV module included in Python 
standard library ?


You'll find there all the needed information for reading and interpreting CSV 
files without having to implement the raw parsing, and have there rows in a 
form ready to use for inserting objects in your model.


For performance's sake, it is advised to use bulk inserts or updates instead on 
individual saves on the Django side if your CSV files contain a lot of data.


Best


Eric


From: django...@googlegroups.com  on behalf of BBG 

Sent: Wednesday, September 26, 2018 6:04:09 PM
To: Django users
Subject: Can anyone share code for uploading csv or excel file to sqlite3 
database.

I want to create upload bulk data. Can anyone share code to upload csv or excel 
file.

--
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 djang...@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/fc5736a8-3396-491b-b265-853f46fdad87%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 
dj

Re: store CSV content to database in django

2018-09-28 Thread PASCUAL Eric
Hi,


Didn't you find material in the documentation I pointed you towards ? Which 
point do you miss exactly ?


Best


Eric


From: django-users@googlegroups.com  on behalf 
of BBG 
Sent: Thursday, September 27, 2018 8:40:12 PM
To: Django users
Subject: store CSV content to database in django

Can anyone share code for uploading CSV file content to database.

--
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/410cc78c-7efd-485a-85a5-582775b4eb63%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/VI1P193MB0432AF70CF8F8C7B73737C5A8CEC0%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Can anyone share code for uploading csv or excel file to sqlite3 database.

2018-09-27 Thread PASCUAL Eric
Hi,


Have you studied the documentation of the CSV module included in Python 
standard library ?


You'll find there all the needed information for reading and interpreting CSV 
files without having to implement the raw parsing, and have there rows in a 
form ready to use for inserting objects in your model.


For performance's sake, it is advised to use bulk inserts or updates instead on 
individual saves on the Django side if your CSV files contain a lot of data.


Best


Eric


From: django-users@googlegroups.com  on behalf 
of BBG 
Sent: Wednesday, September 26, 2018 6:04:09 PM
To: Django users
Subject: Can anyone share code for uploading csv or excel file to sqlite3 
database.

I want to create upload bulk data. Can anyone share code to upload csv or excel 
file.

--
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/fc5736a8-3396-491b-b265-853f46fdad87%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/VI1P193MB0432BA7E9175A8B8D12BF05A8C140%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: error at re_path

2018-09-24 Thread PASCUAL Eric
Hi,


Not 100% sure, but I think that the 'p' should be a "P" (capital).


I've always used the capital version, since it's was is shown in the docs and 
examples, so I can't say if lowercase 'p' works too.


Eric

From: django-users@googlegroups.com  on behalf 
of shiva kumar 
Sent: Sunday, September 23, 2018 9:01:18 PM
To: django-users@googlegroups.com
Subject: error at re_path

getting error saying page not found when using re_path for defining our own url 
pattern.


re_path(r'^home/(?p[0-9]{4})/$',views.home1),

this was how i used the function and it showing error at ?p.


is there any mistake suggest a solution.

--
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/CAMsYeuHzbhA0Pu5gm7t0G4kuMENKf-CNPWQURHSLajGfhDskBg%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/AM6P193MB0421AEB1A8D5E522A682CBC58C170%40AM6P193MB0421.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Django restapi get post

2018-09-12 Thread PASCUAL Eric
Hi,


It depends if the structure of the data you want to post is the same as the one 
your retrieve with a GET, and if it fits with the underlying model. In this 
case, the same serializer can be used for both operations. Pay attention 
however that things can be more complex if the involved model uses relations. 
In this case, using the same serializer is not always applicable.


If not possible, you'll need to define one for data retrieval (you can 
configure it so that all fields are read-only to be sure it will not be used 
incorrectly) and another one to model the data you'll send for a POST.


Eric


From: django-users@googlegroups.com  on behalf 
of TimT Vogt 
Sent: Wednesday, September 12, 2018 11:04:39 AM
To: django-users@googlegroups.com
Subject: Django restapi get post

Hi Group
I am making an Django backend to out data with a rest API to angular frontend.

The rest-API/ GET works😀.
The POST: do I ajust the current serializer?
Or do I need to create another serializer in ABN New app with a recieving model?

Verstuurd vanaf mijn iPhone

--
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/96859EB9-17EF-49C4-ADD6-3D912749FF5B%40gmail.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/DB7P193MB0426614C49AF4D4ADFB005B18C1B0%40DB7P193MB0426.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Trouble installing Django

2018-09-04 Thread PASCUAL Eric
Hi Phil,


As suggested by other posters, creating a virtualenv is the safest way to work 
with Python, since it avoids tampering with the system level installation (f.i. 
several Linux distros use Python for a lot of their system tools in nowadays 
versions) and it lets you have customized environments per project (or projects 
group) not interfering with other ones.


A solution exists one step higher, which allows you to have several different 
versions of Python (not only 2 and 3, but 2.x, 2.y, 3.z,...) alongside and 
select which one a given project uses. It's name is pyenv, and it can be found 
here : https://github.com/pyenv/pyenv


In addition to managing different versions of Python on the same system, you 
can also create virtualenvs attached to them, as you would do with a standard 
Python installation.


And of course, everything runs  in user space, so no need for sudo or admin 
rights. Plus some goodies such as automatically selecting the right pyenv (i.e. 
Python version plus virtualenv) when you cd to a directory, if a 
".python-version" file containing its name exists in it or in one of its 
ancestors. Have a look to the Web page referenced above for more detail.

I work on various projects targeting systems or Docker containers with 
different Python versions, and the pyenv+virtualenv way is the easiest and most 
comfortable I've ever used.

Best.

Eric



From: django-users@googlegroups.com  on behalf 
of Phil Campaigne 
Sent: Monday, September 3, 2018 7:35:09 PM
To: Django users
Subject: Trouble installing Django

I have successfully installed python 3.7 and virtualenv. on my MACBook Pro with 
MAC High Sierra  10.6
Now I am having trouble installing Django
I don't understand the error message I am getting...especially teh last line.

Owners-MacBook-Pro:realityBB owner$ pip install Django
Collecting Django
  Downloading 
https://files.pythonhosted.org/packages/f8/1c/31112c778b7a56ce18e3fff5e8915719fbe1cd3476c1eef557dddacfac8b/Django-1.11.15-py2.py3-none-any.whl
 (6.9MB)
100% || 7.0MB 2.2MB/s
Requirement already satisfied: pytz in 
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python 
(from Django) (2013.7)
Installing collected packages: Django
Could not install packages due to an EnvironmentError: [Errno 13] Permission 
denied: '/Library/Python/2.7/site-packages/Django-1.11.15.dist-info'
Consider using the `--user` option or check the permissions.

--
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/2d82fa91-1cd0-4a16-9ebd-568e7aeb8b2e%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/AM6P193MB0421D1F73770EFB6290AD4668C030%40AM6P193MB0421.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: text editor

2018-09-03 Thread PASCUAL Eric
As already requested earlier by other posters, please STOP this totally useless 
and sterile discussion.


As Gerald Brown wrote, the best editor is the one you feel the most productive 
and comfortable with. Full stop. Everybody has his own background, habits and 
tastes, hence there is nothing such as a "best editor".


My "best editor" is Vim. It's unlikely that this is the choice for the majority 
of people here. QED.


From: django-users@googlegroups.com  on behalf 
of ireoluwa fakeye 
Sent: Monday, September 3, 2018 12:28:42 PM
To: django-users@googlegroups.com
Subject: Re: text editor

Vs code

On Sun, 2 Sep 2018, 06:41 sankar ardhas, 
mailto:sankarard...@gmail.com>> wrote:

Hi to all,
Which is the best editor for django framework  in Ubuntu os 18.04

Get Outlook for Android




On Sun, Sep 2, 2018 at 1:46 AM +0530, "RONAK JAIN" 
mailto:jainronak...@gmail.com>> wrote:

Namaste !!

Dear ,

I have two models categories and Project.

 created like that :

class Category(models.Model):
categorys = models.ManyToManyField('Category',blank=True)
name = models.CharField(max_length=100)
created_at = models.DateTimeField(auto_now=False, auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)



class Meta:
verbose_name_plural = "Categories"

def __str__(self):
return self.name

def __unicode__(self):
return self.categorys

class Project(models.Model):
categorys = models.ManyToManyField('Category',blank=True)
name = models.CharField(max_length=100)
description = models.CharField(max_length=100)
created_at = models.DateTimeField(auto_now=False, auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
photo = models.ImageField(upload_to="pictures")


def __str__(self):
return self.name

def __unicode__(self):
return self.categorys

and Views I did here :

from web.models import Category,Project

class Portfolio(TemplateView):
template_name = "web/protfolio.html"

def post(self, request, *args, **kwargs):
context = self.get_context_data()
return super(TemplateView, self).render_to_response(context)

def portfolio(request):
  context = RequestContext(request)
  # Project_list = Project.objects.order_by('-likes')[:3]
  # context_dict = {'Project': project_list}
  # return render(template_name, context_dict, context
  brand_list = Category.objects.all()
  return render(template_name, {'brand_list' : brand_list}, context)

I need correct relationship both I mean project and categories. How can I do 
correct here ?
Note : I attached picture please analyse briefly.

How to do approch html page and   I want  the html(view) page should load from 
our db.
please give me quickly answer.
How can i do ?


Thanks
Ronak

--
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/63ecd6f1-411a-4581-b245-296efbd49303%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/39ABAA35669F59A4.eb8de1ab-f7fe-4f09-ac86-ab24def151d1%40mail.outlook.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.g

Re: django production

2018-07-03 Thread PASCUAL Eric
Hi Kamal,


Of course you can. It's just a matter of defining virtual hosts in Nginx 
configuration and route them to the different Gunicorns serving your apps, 
based on the host found in the requests URLs.


Best regards


Eric


From: django-users@googlegroups.com  on behalf 
of Kamal Sharma 
Sent: Tuesday, July 3, 2018 9:01:09 AM
To: django-users@googlegroups.com
Subject: django production

Dear Django community,

i have deployed my django project at production server with gunicorn and nginx 
and it is working good.

My question is can i deploy more then one django project on production 
server(ubuntu 16.04) for running two websites?

Thank you

Kamal Sharma

--
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/CAByCWTQ-_wYAYZAB1r-wCHwXdJVxrOViHqTfg5dK%2BCKmJSqw5g%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/VI1P193MB0432BDA408F9E8B7B8197E388C420%40VI1P193MB0432.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: prevent AppConfig.ready() from running twice

2018-06-23 Thread PASCUAL Eric
IMHO, some of (a lot of ?) the "classical" GOF patterns do not really apply to 
Python (or at least are not necessary, when not making things more confuse). 
They are often a consequence of constraints and limitations of statically 
compiled languages such as C++, Java and alike used at the time they have been 
created, but they loose most of their interest for languages such as Python.


If the singleton instance is used internally by your application code, and 
apart if you have really good reasons for making things more complicated, juts 
use a module level variable to store the instance, and initialize it at 
application start. Of course, forbid yourself to write to this variable from 
elsewhere than the app initialization code.


If the singleton creation can be called from other places (f.i. if a lazy 
initialization strategy is used), and if there are possibilities for it to be 
called several times, a guard can be implemented by providing a factory 
function which will test if the instance is currently None, instantiate one if 
needed, store it in the module variable, and return the module variable at the 
end. It would look like this:


_singleton_instance = None


def get_singleton():

if _singleton_instance is None:

_singleton_instance = 

return _singleton_instance


The '_' prefix of the singleton variable is use to indicate that this is a 
"private" variable which must not be referred to (even in read access) from 
outside the module.


Hope this helps.


Regards


Eric


From: django-users@googlegroups.com  on behalf 
of Mike Dewhirst 
Sent: Saturday, June 23, 2018 2:01:06 AM
To: django-users@googlegroups.com
Subject: Re: prevent AppConfig.ready() from running twice

Is there a python singleton pattern which might work?

Connected by Motorola


Melvyn Sopacua  wrote:

On donderdag 21 juni 2018 16:23:23 CEST clavierpla...@gmail.com wrote:

> If it helps, here is the reason I need to override this multi-instantiation
> behavior: my application launches a multiprocessing.Process at startup to
> monitor and run background tasks. Having more than one background Process
> running at once is going to wreak havoc on the application. I've looked at
> other options to accomplish similar purposes, but those would all be
> instantiated multiple times, also.
>
> Any suggestions?

Use a locked pidfile to prevent multiple daemons starting up. I recall the
python-daemon package being capable of this (and lots of other good stuff).

https://pagure.io/python-daemon/
--
Melvyn Sopacua

--
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/139066525.eYAS18T7Ez%40fritzbook.
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/wb0bbtt2xa79lb1b10sny7md.1529712066075%40email.android.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/DB7P193MB0331E4C4C900D305CF7AA1308C740%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Please give the steps to follow this:

2018-06-06 Thread PASCUAL Eric
Templates contain standard HTML code (or any other text based content) and 
template directives, delimited by  '{% %}'. They can also contain placeholders, 
delimited by '{{ }}', which content is processed and replaced with the 
resulting value. The resulting values are basically the ones you pass using the 
"template context". You can add filters (after the '|' symbol) for 
post-processing the value before injecting it in the template.


To answer your precise question, the {% load static %} directive is inserted at 
the beginning of your HTML template to instruct the templating engine that the 
static resolution mechanism functions are used.


All this should be clear if you study Django templates documentation and the 
accompanying examples.


Eric


From: django-users@googlegroups.com  on behalf 
of Avitab Ayan Sarmah 
Sent: Wednesday, June 6, 2018 6:42:51 PM
To: Django users
Subject: Please give the steps to follow this:


  1.  In your templates, use the 
static
 template tag to build the URL for the given relative path using the configured 
STATICFILES_STORAGE.

{% load static %}



  2.  Store your static files in a folder called static in your app. For 
example my_app/static/my_app/example.jpg.

How do i use the static template tag?Because in my templates there is only html 
files.Where do i add the statement {% load static %}? comment please

--
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/81a53388-6929-4bac-a12e-af9d46724004%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/DB7P193MB03313CDD36256B3F3146C0E18C650%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Open Sqlite database file directly in django

2018-05-24 Thread PASCUAL Eric
Hi,


The content of the context dict can be anything, including of course values 
read from the database thanks to the sqlite3 lib. What Django generic views 
working with templates do is transfering for you the object field values to 
context entries and also automating the creation of form fields based on the 
model introspection.


WRT to you question about the size of the data, it depends on what you want to 
do. If you plan to display thousands of records in a single HTML page, it will 
not very efficient for sure and the browser may choke in extreme situations. To 
work around this, you can either implement pagination by yourself, using f.i. 
AJAX requests to return chunks of data as JSON packets and process them by a 
bit of Javascript on the client side to update your page. You can also look for 
JS widgets implementing this for you. I remember having used Datatables 
(https://datatables.net/) a while ago, and it does its job pretty well.

DataTables Table plug-in for jQuery
datatables.net
Create customised, editable tables in minutes with Editor for DataTables. Save 
your time writing yet another CRUD application - Editor is a premium extension 
created to produce complex, fully editable tables that take full advantage of 
all of the features of DataTables.

Regards


Eric


From: django-users@googlegroups.com  on behalf 
of Sourabh Jaiswal 
Sent: Thursday, May 24, 2018 8:22:17 AM
To: Django users
Subject: Re: Open Sqlite database file directly in django

Hi,

Thanks a Lot for your reply.

Using standard python lib you are saying that I should send the data from view 
to template render using context dictionary.. right?

But in my case data can be huge... Is that a good way to do it?

Regards,
Sourabh Jaiswal.

On Tuesday, May 22, 2018 at 5:55:32 PM UTC+5:30, Sourabh Jaiswal wrote:
Hi,

Is there any way to open sqlite db directly in django.

I am working on an application for which a back end script creates a database 
for every execution.
The database consists of multiple tables and I have to show those tables on the 
web site made in django.

Is there any other way around for this?

Any help will be greatly appreciated.

Thanks,
Jaiswal.

--
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/e15842ab-861f-4b28-ac92-a1109e61be95%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/DB7P193MB0331F3FF8D9BA571A59F9DDE8C6A0%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Open Sqlite database file directly in django

2018-05-22 Thread PASCUAL Eric
Thanks for the tip, I didn't notice this management command before.


Eric


From: django-users@googlegroups.com  on behalf 
of Vinicius Assef 
Sent: Tuesday, May 22, 2018 6:56:20 PM
To: django-users@googlegroups.com
Subject: Re: Open Sqlite database file directly in django

It depends.

If tables have always the same schema and only their data is
different, you can use `manage.py inspectdb` [0] to create models and
develop your views.


[0] https://docs.djangoproject.com/en/2.0/ref/django-admin/#inspectdb



On 22 May 2018 at 11:01, PASCUAL Eric  wrote:
> Re,
>
>
> But you'll not be able to access the sqlite DB through Django models, since
> it will not have the proper schema.
>
>
> Eric
> ____
> From: PASCUAL Eric
> Sent: Tuesday, May 22, 2018 3:59:35 PM
> To: Django users
> Subject: Re: Open Sqlite database file directly in django
>
>
> Hi Jaiswal,
>
>
> You can use the Python sqlite3 standard lib for opening this database and
> manipulate it, and then display data using views written with Django.
>
>
> Eric
>
> 
> From: django-users@googlegroups.com  on
> behalf of Sourabh Jaiswal 
> Sent: Tuesday, May 22, 2018 8:02:03 AM
> To: Django users
> Subject: Open Sqlite database file directly in django
>
> Hi,
>
> Is there any way to open sqlite db directly in django.
>
> I am working on an application for which a back end script creates a
> database for every execution.
> The database consists of multiple tables and I have to show those tables on
> the web site made in django.
>
> Is there any other way around for this?
>
> Any help will be greatly appreciated.
>
> Thanks,
> Jaiswal.
>
> --
> 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/d24eda2f-8051-42eb-9081-b986dfd234c3%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/DB7P193MB0331365FA7C61731D9F3F0D68C940%40DB7P193MB0331.EURP193.PROD.OUTLOOK.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/CAFmXjSBwpOAXa-ZsAj8kZnvVetjrodkaeaXssc4B2-FerjcHnA%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/DB7P193MB0331EC8A0C09225164AA81708C940%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Open Sqlite database file directly in django

2018-05-22 Thread PASCUAL Eric
Re,


But you'll not be able to access the sqlite DB through Django models, since it 
will not have the proper schema.


Eric

From: PASCUAL Eric
Sent: Tuesday, May 22, 2018 3:59:35 PM
To: Django users
Subject: Re: Open Sqlite database file directly in django


Hi Jaiswal,


You can use the Python sqlite3 standard lib for opening this database and 
manipulate it, and then display data using views written with Django.


Eric


From: django-users@googlegroups.com  on behalf 
of Sourabh Jaiswal 
Sent: Tuesday, May 22, 2018 8:02:03 AM
To: Django users
Subject: Open Sqlite database file directly in django

Hi,

Is there any way to open sqlite db directly in django.

I am working on an application for which a back end script creates a database 
for every execution.
The database consists of multiple tables and I have to show those tables on the 
web site made in django.

Is there any other way around for this?

Any help will be greatly appreciated.

Thanks,
Jaiswal.

--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/d24eda2f-8051-42eb-9081-b986dfd234c3%40googlegroups.com<https://groups.google.com/d/msgid/django-users/d24eda2f-8051-42eb-9081-b986dfd234c3%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/DB7P193MB0331365FA7C61731D9F3F0D68C940%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Open Sqlite database file directly in django

2018-05-22 Thread PASCUAL Eric
Hi Jaiswal,


You can use the Python sqlite3 standard lib for opening this database and 
manipulate it, and then display data using views written with Django.


Eric


From: django-users@googlegroups.com  on behalf 
of Sourabh Jaiswal 
Sent: Tuesday, May 22, 2018 8:02:03 AM
To: Django users
Subject: Open Sqlite database file directly in django

Hi,

Is there any way to open sqlite db directly in django.

I am working on an application for which a back end script creates a database 
for every execution.
The database consists of multiple tables and I have to show those tables on the 
web site made in django.

Is there any other way around for this?

Any help will be greatly appreciated.

Thanks,
Jaiswal.

--
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/d24eda2f-8051-42eb-9081-b986dfd234c3%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/DB7P193MB0331177AEF4D72DDD2C23FC88C940%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Advice needed: One big model or many apps with highly interlinked data tables?

2018-04-17 Thread PASCUAL Eric
Hi Mikkel,


When facing this type of situation, I tend to use one of these two options, 
depending on the number of model classes:


  *   if the number of classes is reasonable, I use a single app, but implement 
the models in a model package, distributing the classes into modules inside 
this package so that each one is reasonable in size and packs together closely 
related classes. Same for the views BTW.
  *   if this would not be enough, I break the global app into smaller ones, 
trying to map the "business domains" of the application. The guideline here is 
that the dependencies between domains should be kept as reduced as possible. A 
side effect of this approach is that it can happen that some of the apps are 
generic enough to be reusable in other Django projects.


I don't pretend that this is the "official" way to proceed. Maybe there are 
smarter way to do.


Best regards


Eric PASCUAL

Centre Scientifique et Technique du Bâtiment
290 route des Lucioles - BP 209
06904 SOPHIA ANTIPOLIS CEDEX
http://www.cstb.fr


From: django-users@googlegroups.com  on behalf 
of Mikkel Kromann 
Sent: Saturday, April 14, 2018 3:52:38 PM
To: Django users
Subject: Advice needed: One big model or many apps with highly interlinked data 
tables?

Hi.

I'm new to Django, and I'm working my way into Django by going through the nice 
Djangoproject.com turorial.
I'm trying to find out whether Django is the right tool for my task, which is 
maybe a bit unusual for Django.

My task is to build a web interface to a database for an calculation tool made 
in Python.
The database will contain maybe up to 100.000 pieces of data (mostly decimal 
fields), and the tool will import this data, do some calculations and write 
some results back to the database.

My Django web interface should allow the user to view, add, delete and edit the 
data in the database, and view the results with tables and charts.
The data is organised in various chunks:

- "Sets" which lend themselves very nicely to Django models, i.e. 
HouseholdType, Item, City, Month, Year
- "Maps", which are user defined ManyToOne or ManyToMany relations between the 
various sets (can probably be worked into the "sets" models)
- "Data Tables", which contains the main load of data, having the "sets" as 
foreign keys (e.g. "Demand" for each HouseholdType, Item, City, Month and year)
- "Results tables", calculated by the tool but in structure quite similar to 
the "Data tables"

I will have roughly 10 sets, 10 maps. 20-30 data tables and 10-20 result tables.
I understand that putting all these into a one app will create biiig models.py 
and views.py files, which is probably a bad idea.

On the other hand, splitting the sets, maps and tables into several apps does 
not seem to be an ideal solution either.
All the tables and the maps will be models that have foreign keys to the "sets" 
models.
My understanding so far is, that it is also bad to have a lot of interlinkage 
between the various apps.

An intermediate solution might be, that if I make a "Sets" app containing all 
the models that are going to be primary key in the other apps, then the 
interlinkages between the apps is somewhat simplified.

Any thoughts or advice?


cheers, Mikkel



--
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/7b0f436c-4bef-4c1f-b513-e18b820fb570%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/DB7P193MB0331DEFE1ECAFCE751BE57FD8CB70%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Decoupling Postgres database credentials in django for deployment.

2018-04-01 Thread PASCUAL Eric
How is github "security" going to help you keep your passwords safe


IMHO, it does not.


As you wrote, env vars configured on the target system (be it a bare server or 
a Dockerized environment in the cloud) seem to be safer on this point since not 
stored anywhere but on the target.


Eric


From: django-users@googlegroups.com  on behalf 
of Derek 
Sent: Saturday, March 31, 2018 3:46:53 PM
To: Django users
Subject: Re: Decoupling Postgres database credentials in django for deployment.

How is github "security" going to help you keep your passwords safe and why is 
this better than ENV variables (which most of use without any problems).?

On Friday, 30 March 2018 16:50:03 UTC+2, Bill Torcaso wrote:

I have a concern about using environment variables to hold secret information, 
and an opinion about it.

IF

DEBUG is enabled, and there is a 500 server internal error, and the default 500 
template is used to render the response,

THEN

all of your secret information is shown in the browser output

Of course, DEBUG should never be enabled in production.  But a single human 
error might make it happen.

I would prefer to trust Github security and long passwords than to think I am 
infallible about setting DEBUG.

Note that this is certainly what happens when I run on a Vagrant VM, and I 
think it would be the same in a Docker-like container.




On Thursday, March 29, 2018 at 4:24:40 PM UTC-4, prince gosavi wrote:
Hi,
I have made a django project and want to deploy it on cloud.
Before that i want to decouple all the private information.
I want to decouple the database info too, like the username password etc.
Any help is 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/cea076e8-4dcc-4c7e-a845-92f1d914b2c0%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/DB7P193MB0331EAF64F8BEC279D58BE618CA70%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Decoupling Postgres database credentials in django for deployment.

2018-03-30 Thread PASCUAL Eric
You're perfectly right about the "500 Error + DEBUG" case.


One solution is to set DEBUG to off by default, and turn it on by code in the 
setting module if detecting  that the app is executing in a dev or Q&A 
environment. Depending on your context, this can be done with rules based on 
the host name or some other properties of the target systems.


Best


Eric


From: django-users@googlegroups.com  on behalf 
of Bill Torcaso 
Sent: Friday, March 30, 2018 4:50:02 PM
To: Django users
Subject: Re: Decoupling Postgres database credentials in django for deployment.


I have a concern about using environment variables to hold secret information, 
and an opinion about it.

IF

DEBUG is enabled, and there is a 500 server internal error, and the default 500 
template is used to render the response,

THEN

all of your secret information is shown in the browser output

Of course, DEBUG should never be enabled in production.  But a single human 
error might make it happen.

I would prefer to trust Github security and long passwords than to think I am 
infallible about setting DEBUG.

Note that this is certainly what happens when I run on a Vagrant VM, and I 
think it would be the same in a Docker-like container.




On Thursday, March 29, 2018 at 4:24:40 PM UTC-4, prince gosavi wrote:
Hi,
I have made a django project and want to deploy it on cloud.
Before that i want to decouple all the private information.
I want to decouple the database info too, like the username password etc.
Any help is 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/f5a1498a-3383-4219-b10e-e3e64f164658%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/DB7P193MB03311541D366207EF76069C28CA10%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Decoupling Postgres database credentials in django for deployment.

2018-03-30 Thread PASCUAL Eric
Env vars are considered bad in contexts where everything runs in the same... 
environment. And I too have considered them as hacks or as options to avoid by 
all means.


But times are changing, and nowadays there is a move towards containerized 
apps, even outside the cloud context. And we are no more now in the traditional 
initial hype phase, which means that the approach has proven its benefits (and 
also its constraints and maybe weaknesses). As an example of a real life work 
project, I've deployed a docker compose stack on RaspberryPi's for running an 
instrumentation system, to avoid having to install each and every component and 
manage the possible conflicts or interferences between them. It works 24/7 for 
months now without any hiccup. Containers really shine for relieving you from 
DLLs/shared libs/packages/... hell.


That being said, in such an architecture, each container is an isolated 
environment, and thus you can use env vars without fearing that someone else 
could tampered with them.


So perhaps the time is coming for considering env vars are no more the evil :) 
It depends on when and how you use them.


Best


Eric


From: django-users@googlegroups.com  on behalf 
of Antonis Christofides 
Sent: Friday, March 30, 2018 2:11:02 PM
To: django-users@googlegroups.com
Subject: Re: Decoupling Postgres database credentials in django for deployment.


Environment variables are the best option for not embedding sensitive 
information in files
However some people (me that is :-) think that environment variables, though 
widely used, are an ugly hack for this problem.


I explain the way I do it (TLDR; production settings must be stored in a 
different "deployment" repository, preferably with any secrets encrypted) in 
https://www.crowdcast.io/e/deploying-django, from 38m10s to 46m30s.


Regards,


Antonis

Antonis Christofides
http://djangodeployment.com

On 2018-03-30 13:06, PASCUAL Eric wrote:

Hi,


Environment variables are the best option for not embedding sensitive 
information in files which have chances to be stored in places such as external 
source repositories (GitHub et al.).


If you are working with orchestrators such as Kubernetes, you can use the 
"secrets", which are specialized shared configuration data, stored in encrypted 
form. As shared configuration data, they bring the extra benefit over env vars 
of being manageable from a single central place, and then distributed to all 
the replicas and services which need them.


Best regards


Eric


From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
<mailto:django-users@googlegroups.com> on behalf 
of Andréas Kühne <mailto:andreas.ku...@hypercode.se>
Sent: Friday, March 30, 2018 11:08:52 AM
To: django-users@googlegroups.com<mailto:django-users@googlegroups.com>
Subject: Re: Decoupling Postgres database credentials in django for deployment.

Hi,

I am sorry, but this doesn't really make sense. What do you mean by decoupling 
the data?

Deploying to the cloud, will mean that you will need to setup a new database 
for your project - there you will get a completly new database, that won't be 
connected to your development data in any way.

You can then add system variables for the username and password for the 
database - and thats about all you need?

Regards,

Andréas

2018-03-29 22:24 GMT+02:00 prince gosavi 
mailto:princegosav...@gmail.com>>:
Hi,
I have made a django project and want to deploy it on cloud.
Before that i want to decouple all the private information.
I want to decouple the database info too, like the username password etc.
Any help is 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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/4b09223d-d58f-4fda-b3f7-64b230960d94%40googlegroups.com<https://groups.google.com/d/msgid/django-users/4b09223d-d58f-4fda-b3f7-64b230960d94%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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto:django-users@googlegroup

Re: Decoupling Postgres database credentials in django for deployment.

2018-03-30 Thread PASCUAL Eric
Hi,


Environment variables are the best option for not embedding sensitive 
information in files which have chances to be stored in places such as external 
source repositories (GitHub et al.).


If you are working with orchestrators such as Kubernetes, you can use the 
"secrets", which are specialized shared configuration data, stored in encrypted 
form. As shared configuration data, they bring the extra benefit over env vars 
of being manageable from a single central place, and then distributed to all 
the replicas and services which need them.


Best regards


Eric


From: django-users@googlegroups.com  on behalf 
of Andréas Kühne 
Sent: Friday, March 30, 2018 11:08:52 AM
To: django-users@googlegroups.com
Subject: Re: Decoupling Postgres database credentials in django for deployment.

Hi,

I am sorry, but this doesn't really make sense. What do you mean by decoupling 
the data?

Deploying to the cloud, will mean that you will need to setup a new database 
for your project - there you will get a completly new database, that won't be 
connected to your development data in any way.

You can then add system variables for the username and password for the 
database - and thats about all you need?

Regards,

Andréas

2018-03-29 22:24 GMT+02:00 prince gosavi 
mailto:princegosav...@gmail.com>>:
Hi,
I have made a django project and want to deploy it on cloud.
Before that i want to decouple all the private information.
I want to decouple the database info too, like the username password etc.
Any help is 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/4b09223d-d58f-4fda-b3f7-64b230960d94%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/CAK4qSCeZFiw9D7Sa213H_MkPgcH-aTQ3fk-j5HLjZdHK%2B5ps%2BQ%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/DB7P193MB0331039E86ABAEFF1B794D898CA10%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


data manipulation code in custom migrations

2018-03-28 Thread PASCUAL Eric
Hello,


I recently ran into a problem with a custom migration containing code 
manipulating the data.


The simplified scenario is:

  *   a given model has been defined with its set of fields. So far so good.
  *   later on, a new field has been added, intended to contain a required 
read-only value which is automatically generated when creating new instances
  *   to fulfill the required constraint for existing instances, a custom 
migration has been added (let's call it M1 for reference) to generate the 
missing values. No problem, all (migrations, application,...) is working fine.

Later on, a new field has been added to the model (let's call it F). The 
associated automatic migration (let's call it M2) and the application still run 
fine.


A problem now occurs when running unit tests. At the time the temporary test 
database creation process runs, in hangs on migration M1. The reason is that 
when it runs, it loads the current model class definition which includes the 
field F. But this field does not exist yet in the database (since created later 
by the migration M2). Shortly said, the problem comes from the model and the 
database not being in sync when running M1.


Since I imagine that this situation is not uncommon, there should be an 
appropriate method to be applied in this case. Could anybody give some hints 
about the right way to proceed please ? Thanks in advance.


Best regards


Eric

-- 
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/DB7P193MB033118E2C1336E608FE94EC58CA30%40DB7P193MB0331.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Syntax Error when trying to migrate to Postgresql

2018-02-17 Thread PASCUAL Eric
Office oriented editors tend to take initiatives for making the text prettier 
(at least, according to their "standards" 😊).


For programming tasks, you'd better use real programming editors. There are a 
lot of very good ones which are free, and even full IDEs. I'd strongly suggest 
PyCharm Community Edition in this category (I'm not endorsed by JetBrain and 
have no connection at all with them, apart from being a very happy user of 
their products).


Best


Eric

From: django-users@googlegroups.com  on behalf 
of Joe 
Sent: Thursday, February 15, 2018 4:12:54 AM
To: Django users
Subject: Re: Syntax Error when trying to migrate to Postgresql

The problem was with the quotes being weird format, had to copy and paste the 
correct quotes in for it.  Thanks for the help!!

On Wednesday, February 14, 2018 at 9:59:06 PM UTC-5, Joe wrote:
I used TextEdit on Mac to edit the files, maybe using a different editor would 
work better.

On Wednesday, February 14, 2018 at 5:41:24 PM UTC-5, larry@gmail.com wrote:
On Wed, Feb 14, 2018 at 5:32 PM, Joe  wrote:
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.postgresql',
> 'NAME': ‘postgres’,
> 'USER': ‘postgres’,
> 'PASSWORD': ‘*’,
> 'HOST': ‘localhost’,
> 'PORT': ‘8000’,
> }
> }

Looks like the quotes around the values are some non ascii character.
On my screen I see this:

‘

Change it to ' or "

Did you copy/paste that from Word perhaps?

--
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/872de896-e541-466b-a158-5bcc59e7914b%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/AM5P193MB0083482D171A3461E8EA184C8CCA0%40AM5P193MB0083.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: AttributeError: 'module' object has no attribute 'lru_cache' with python 3.6.4 and Django 2.0.2

2018-02-14 Thread PASCUAL Eric
Maybe it works like this in Windows (I don't know since having left this world 
since long now), but Greng mentioned a Debian environment inside his Docker 
container. Hence my remark.


By the way you mentioned "DLLs". Geng's trouble seems to be related to Python 
packages finding, not binary libs. In Linux, they are governed by different 
search paths.


Eric


From: django-users@googlegroups.com  on behalf 
of Matthew Pava 
Sent: Wednesday, February 14, 2018 4:05:57 PM
To: 'django-users@googlegroups.com'
Subject: RE: AttributeError: 'module' object has no attribute 'lru_cache' with 
python 3.6.4 and Django 2.0.2


I’m not familiar with Docker, but I did have to add the path to Python 3.6 DLLs 
in my WSGI configuration in my Apache configuration file.

WSGIPythonPath ${project_path};${virtualenv};C:/Python36/DLLs;



From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of PASCUAL Eric
Sent: Wednesday, February 14, 2018 8:52 AM
To: Django users
Subject: Re: AttributeError: 'module' object has no attribute 'lru_cache' with 
python 3.6.4 and Django 2.0.2



Hi,



Normally you shouldn't have to add site-packages in the PYTHONPATH since it is 
supposed to be already. If not, packages installed via "sudo pip install" would 
not be found.



I've packaged a lot of applications in Docker containers, and never had to 
modify PYTHONPATH.



Your problem is maybe be lurking elsewhere than PYTHONPATH, and this change has 
just created a new one which is hiding the original one, but not solving it at 
all.



Best



Eric



From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
mailto:django-users@googlegroups.com>> on behalf 
of Greng Fortezza mailto:greng@gmail.com>>
Sent: Wednesday, February 14, 2018 3:02:28 PM
To: Django users
Subject: AttributeError: 'module' object has no attribute 'lru_cache' with 
python 3.6.4 and Django 2.0.2



Hi,



I'm trying to set up the following configuration in Docker

python: 3.6.4

Django: 2.0.2

Apache/2.4.10 (Debian)



First, I was getting the error



ImportError: No module named django.core.wsgi



Then I added Django to PYTHONPATH



export PYTHONPATH="/usr/local/lib/python3.6/site-packages"



the previous problem has gone away but now there is another one



AttributeError: 'module' object has no attribute 'lru_cache'

Apache configs contains the following line



WSGIScriptAlias / /www/settings/wsgi.py

where /www/settings/wsgi.py is  actual path to wsgi.py file.



What could be wrong?



Thanks,

Greng

--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/02803efb-92a9-4958-9a52-f77bee7de89b%40googlegroups.com<https://groups.google.com/d/msgid/django-users/02803efb-92a9-4958-9a52-f77bee7de89b%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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/AM5P193MB008328E4760DBF0DA724D2238CF50%40AM5P193MB0083.EURP193.PROD.OUTLOOK.COM<https://groups.google.com/d/msgid/django-users/AM5P193MB008328E4760DBF0DA724D2238CF50%40AM5P193MB0083.EURP193.PROD.OUTLOOK.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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https

Re: AttributeError: 'module' object has no attribute 'lru_cache' with python 3.6.4 and Django 2.0.2

2018-02-14 Thread PASCUAL Eric
Hi,


Normally you shouldn't have to add site-packages in the PYTHONPATH since it is 
supposed to be already. If not, packages installed via "sudo pip install" would 
not be found.


I've packaged a lot of applications in Docker containers, and never had to 
modify PYTHONPATH.


Your problem is maybe be lurking elsewhere than PYTHONPATH, and this change has 
just created a new one which is hiding the original one, but not solving it at 
all.


Best


Eric


From: django-users@googlegroups.com  on behalf 
of Greng Fortezza 
Sent: Wednesday, February 14, 2018 3:02:28 PM
To: Django users
Subject: AttributeError: 'module' object has no attribute 'lru_cache' with 
python 3.6.4 and Django 2.0.2

Hi,

I'm trying to set up the following configuration in Docker
python: 3.6.4
Django: 2.0.2
Apache/2.4.10 (Debian)

First, I was getting the error

ImportError: No module named django.core.wsgi

Then I added Django to PYTHONPATH

export PYTHONPATH="/usr/local/lib/python3.6/site-packages"

the previous problem has gone away but now there is another one

AttributeError: 'module' object has no attribute 'lru_cache'

Apache configs contains the following line

WSGIScriptAlias / /www/settings/wsgi.py

where /www/settings/wsgi.py is  actual path to wsgi.py file.

What could be wrong?

Thanks,
Greng

--
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/02803efb-92a9-4958-9a52-f77bee7de89b%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/AM5P193MB008328E4760DBF0DA724D2238CF50%40AM5P193MB0083.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: importError: Count Not import Django inside Virtualenv

2018-02-14 Thread PASCUAL Eric
Hi Etienne,

I prefer messing with standard distutils/setuptools commands to avoid 
situations like this... ;-)

Messing and restoring system libs is a matter of personnal taste 😃


Eric


From: Etienne Robillard 
Sent: Wednesday, February 14, 2018 11:07:07 AM
To: PASCUAL Eric
Cc: django-users@googlegroups.com
Subject: Re: importError: Count Not import Django inside Virtualenv


Hi Eric,

Le 2018-02-14 à 03:44, PASCUAL Eric a écrit :

Hi,


Hard to say without knowing the exact context, but my gut feeling is that 
you've modified a system wide library at a moment (maybe inadvertently).


My own experience is that it's easy to mess with Python libraries when 
installing packages with sudo , which may happen form time to  time when 
working with virtualenv (or pyenv) since not very long, and being caught up by 
old habits (they tend to survive longer that wanted 😊).


I prefer messing with standard distutils/setuptools commands to avoid 
situations like this... ;-)

Cheers,
Etienne



From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
<mailto:django-users@googlegroups.com> on behalf 
of tango ward <mailto:tangowar...@gmail.com>
Sent: Wednesday, February 14, 2018 3:40:04 AM
To: django-users@googlegroups.com<mailto:django-users@googlegroups.com>
Subject: Re: importError: Count Not import Django inside Virtualenv

Hi Eric,


I tried what you suggested and it works! I was just wondering why my existing 
pet projects have the same problem?

On Wed, Feb 14, 2018 at 10:13 AM, tango ward 
mailto:tangowar...@gmail.com>> wrote:
Hi,

The error message that I am getting is:

Traceback (most recent call last):
  File "manage.py", line 8, in 
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 14, in 
) from exc
ImportError: Couldn't import Django. Are you sure it's installed and available 
on your PYTHONPATH environment variable? Did you forget to activate a virtual 
environment?


@Jason,

It's weird because couple of days, I can still run these pet projects without 
any error. If I go to venv folder virtual/lib/python3.6/site-packages, I can 
see django there. It seems that even though virtualenv is activated, the 
packages I installed inside it are not recognized by the system.


On Wed, Feb 14, 2018 at 5:38 AM, PASCUAL Eric 
mailto:eric.pasc...@cstb.fr>> wrote:

Hi Jarvis,


Can you provide the error messages trace ? It can greatly help understanding 
what's happening.


If you haven't already done this, try to restart from a fresh new virtualenv 
inside which you'll install Django and the additional packages you've added (if 
any). Then restore a copy of your project in this context (if by chance you 
work with git, a simple git clone will do the trick) and test your app again.


Hoping you haven't already messed your system Python by installing stuff in 
sudo mode. The situation could be a little more complicated then.


Best.


Eric

From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
mailto:django-users@googlegroups.com>> on behalf 
of tango ward mailto:tangowar...@gmail.com>>
Sent: Tuesday, February 13, 2018 9:43:45 PM
To: django-users@googlegroups.com<mailto:django-users@googlegroups.com>
Subject: importError: Count Not import Django inside Virtualenv

Hi,

I want to seek some advice about the error. All of my pet projects in my 
desktop are getting the same error even though virtualenv is activated. I can 
confirm that when I started playing around with the projects, I have installed 
Django inside virtualenv without using "sudo". Now, I can't run python 
manage.py runserver and the packages that I am getting whenever I run pip 
freeze are different from before which doesn't include Django in the list.


Any advice pls?


Thanks,
Jarvis
--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/CAA6wQLKp3oz-6FfDzQ%3Dip4XRsuLPSeOCuwkbUuWbe1JNx2YhFA%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAA6wQLKp3oz-6FfDzQ%3Dip4XRsuLPSeOCuwkbUuWbe1JNx2YhFA%40mail.gmail.com?utm_medium=email&utm_source=footer>

Re: importError: Count Not import Django inside Virtualenv

2018-02-14 Thread PASCUAL Eric
Hi,


The copy/paste of the project tree will work of course. Chances are that 
unwanted files can be brought too, but this should not be a problem in a first 
stage.


I have used rsync or tar archives to deploy Django projects in some cases, and 
it worked fine.


Eric


From: django-users@googlegroups.com  on behalf 
of tango ward 
Sent: Wednesday, February 14, 2018 10:09:51 AM
To: django-users@googlegroups.com
Subject: Re: importError: Count Not import Django inside Virtualenv

that's odd. Whenever I test a pacakge, it's always installed first in 
virtualenv. Maybe when I updated my system? Btw, I have some projects which are 
not yet in github, can I just copy and paste them in a new folder with new 
virtualenv?

On Wed, Feb 14, 2018 at 4:44 PM, PASCUAL Eric 
mailto:eric.pasc...@cstb.fr>> wrote:

Hi,


Hard to say without knowing the exact context, but my gut feeling is that 
you've modified a system wide library at a moment (maybe inadvertently).


My own experience is that it's easy to mess with Python libraries when 
installing packages with sudo , which may happen form time to  time when 
working with virtualenv (or pyenv) since not very long, and being caught up by 
old habits (they tend to survive longer that wanted 😊).


Even if far less harmful, then --user option is to avoid for projects related 
libs, for the same reasons.


Eric

From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
mailto:django-users@googlegroups.com>> on behalf 
of tango ward mailto:tangowar...@gmail.com>>
Sent: Wednesday, February 14, 2018 3:40:04 AM
To: django-users@googlegroups.com<mailto:django-users@googlegroups.com>
Subject: Re: importError: Count Not import Django inside Virtualenv

Hi Eric,


I tried what you suggested and it works! I was just wondering why my existing 
pet projects have the same problem?

On Wed, Feb 14, 2018 at 10:13 AM, tango ward 
mailto:tangowar...@gmail.com>> wrote:
Hi,

The error message that I am getting is:

Traceback (most recent call last):
  File "manage.py", line 8, in 
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 14, in 
) from exc
ImportError: Couldn't import Django. Are you sure it's installed and available 
on your PYTHONPATH environment variable? Did you forget to activate a virtual 
environment?


@Jason,

It's weird because couple of days, I can still run these pet projects without 
any error. If I go to venv folder virtual/lib/python3.6/site-packages, I can 
see django there. It seems that even though virtualenv is activated, the 
packages I installed inside it are not recognized by the system.


On Wed, Feb 14, 2018 at 5:38 AM, PASCUAL Eric 
mailto:eric.pasc...@cstb.fr>> wrote:

Hi Jarvis,


Can you provide the error messages trace ? It can greatly help understanding 
what's happening.


If you haven't already done this, try to restart from a fresh new virtualenv 
inside which you'll install Django and the additional packages you've added (if 
any). Then restore a copy of your project in this context (if by chance you 
work with git, a simple git clone will do the trick) and test your app again.


Hoping you haven't already messed your system Python by installing stuff in 
sudo mode. The situation could be a little more complicated then.


Best.


Eric

From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
mailto:django-users@googlegroups.com>> on behalf 
of tango ward mailto:tangowar...@gmail.com>>
Sent: Tuesday, February 13, 2018 9:43:45 PM
To: django-users@googlegroups.com<mailto:django-users@googlegroups.com>
Subject: importError: Count Not import Django inside Virtualenv

Hi,

I want to seek some advice about the error. All of my pet projects in my 
desktop are getting the same error even though virtualenv is activated. I can 
confirm that when I started playing around with the projects, I have installed 
Django inside virtualenv without using "sudo". Now, I can't run python 
manage.py runserver and the packages that I am getting whenever I run pip 
freeze are different from before which doesn't include Django in the list.


Any advice pls?


Thanks,
Jarvis

--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto:django-user

Re: importError: Count Not import Django inside Virtualenv

2018-02-14 Thread PASCUAL Eric
Hi,


Hard to say without knowing the exact context, but my gut feeling is that 
you've modified a system wide library at a moment (maybe inadvertently).


My own experience is that it's easy to mess with Python libraries when 
installing packages with sudo , which may happen form time to  time when 
working with virtualenv (or pyenv) since not very long, and being caught up by 
old habits (they tend to survive longer that wanted 😊).


Even if far less harmful, then --user option is to avoid for projects related 
libs, for the same reasons.


Eric

From: django-users@googlegroups.com  on behalf 
of tango ward 
Sent: Wednesday, February 14, 2018 3:40:04 AM
To: django-users@googlegroups.com
Subject: Re: importError: Count Not import Django inside Virtualenv

Hi Eric,


I tried what you suggested and it works! I was just wondering why my existing 
pet projects have the same problem?

On Wed, Feb 14, 2018 at 10:13 AM, tango ward 
mailto:tangowar...@gmail.com>> wrote:
Hi,

The error message that I am getting is:

Traceback (most recent call last):
  File "manage.py", line 8, in 
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 14, in 
) from exc
ImportError: Couldn't import Django. Are you sure it's installed and available 
on your PYTHONPATH environment variable? Did you forget to activate a virtual 
environment?


@Jason,

It's weird because couple of days, I can still run these pet projects without 
any error. If I go to venv folder virtual/lib/python3.6/site-packages, I can 
see django there. It seems that even though virtualenv is activated, the 
packages I installed inside it are not recognized by the system.


On Wed, Feb 14, 2018 at 5:38 AM, PASCUAL Eric 
mailto:eric.pasc...@cstb.fr>> wrote:

Hi Jarvis,


Can you provide the error messages trace ? It can greatly help understanding 
what's happening.


If you haven't already done this, try to restart from a fresh new virtualenv 
inside which you'll install Django and the additional packages you've added (if 
any). Then restore a copy of your project in this context (if by chance you 
work with git, a simple git clone will do the trick) and test your app again.


Hoping you haven't already messed your system Python by installing stuff in 
sudo mode. The situation could be a little more complicated then.


Best.


Eric

From: django-users@googlegroups.com<mailto:django-users@googlegroups.com> 
mailto:django-users@googlegroups.com>> on behalf 
of tango ward mailto:tangowar...@gmail.com>>
Sent: Tuesday, February 13, 2018 9:43:45 PM
To: django-users@googlegroups.com<mailto:django-users@googlegroups.com>
Subject: importError: Count Not import Django inside Virtualenv

Hi,

I want to seek some advice about the error. All of my pet projects in my 
desktop are getting the same error even though virtualenv is activated. I can 
confirm that when I started playing around with the projects, I have installed 
Django inside virtualenv without using "sudo". Now, I can't run python 
manage.py runserver and the packages that I am getting whenever I run pip 
freeze are different from before which doesn't include Django in the list.


Any advice pls?


Thanks,
Jarvis

--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/CAA6wQLKp3oz-6FfDzQ%3Dip4XRsuLPSeOCuwkbUuWbe1JNx2YhFA%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CAA6wQLKp3oz-6FfDzQ%3Dip4XRsuLPSeOCuwkbUuWbe1JNx2YhFA%40mail.gmail.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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/AM5P193MB0083C66

Re: importError: Count Not import Django inside Virtualenv

2018-02-13 Thread PASCUAL Eric
Hi Jarvis,


Can you provide the error messages trace ? It can greatly help understanding 
what's happening.


If you haven't already done this, try to restart from a fresh new virtualenv 
inside which you'll install Django and the additional packages you've added (if 
any). Then restore a copy of your project in this context (if by chance you 
work with git, a simple git clone will do the trick) and test your app again.


Hoping you haven't already messed your system Python by installing stuff in 
sudo mode. The situation could be a little more complicated then.


Best.


Eric

From: django-users@googlegroups.com  on behalf 
of tango ward 
Sent: Tuesday, February 13, 2018 9:43:45 PM
To: django-users@googlegroups.com
Subject: importError: Count Not import Django inside Virtualenv

Hi,

I want to seek some advice about the error. All of my pet projects in my 
desktop are getting the same error even though virtualenv is activated. I can 
confirm that when I started playing around with the projects, I have installed 
Django inside virtualenv without using "sudo". Now, I can't run python 
manage.py runserver and the packages that I am getting whenever I run pip 
freeze are different from before which doesn't include Django in the list.


Any advice pls?


Thanks,
Jarvis

--
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/CAA6wQLKp3oz-6FfDzQ%3Dip4XRsuLPSeOCuwkbUuWbe1JNx2YhFA%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/AM5P193MB0083C66FCD689270720750708CF60%40AM5P193MB0083.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: How to fetch data from sql server and display on django web pages

2018-02-13 Thread PASCUAL Eric
Hi,


> You may want to check out sqlalchemy they provide a pretty good documentation 
> on what you are aftering


For my understanding, why are you suggesting to use SQLAlchemy while Django 
provides an ORM out of the box ?


SQLAlchemy is required for frameworks such as Flask, which do nothing with 
respect to the data layer, but it's not clear which benefit it could bring here.


Best regards


Eric

From: django-users@googlegroups.com  on behalf 
of sum abiut 
Sent: Monday, February 12, 2018 10:24:07 PM
To: django-users@googlegroups.com
Subject: Re: How to fetch data from sql server and display on django web pages


You may want to check out sqlalchemy they provide a pretty good documentation 
on what you are aftering 
http://docs.sqlalchemy.org/en/latest/dialects/mssql.html

>From you view you can defile a function like so.

view.py

from sqlalchemy import*
from django.shortcuts import render

def connectto_db(request):
engine=create_engine('mssql+pymssql://username:password@servername 
/Ddabname')
connection=engine.connect()
metadata=MetaData()


table=Table('tablename',metadata,autoload=True,autoload_with=engine)
stmt='SELECT * FROM table'
results=connection.execute(stmt).fetchall()
return render(request,'template.html',locals())


then  you can pass the results to your template.html

Hope this helps.

Cheers

On Sun, Feb 11, 2018 at 4:37 PM, Amit Kadivar 
mailto:amit.kadiv...@gmail.com>> wrote:
Please Help me.
How to fetch data from sql server and display them on django web pages through 
nginx web server..




--
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/b5577524-e67d-465f-bb49-e54bca92c88b%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/CAPCf-y5CZ-HAUSbGkTWKe23CfuCMWozoLqL85V52924NpDwd-A%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/AM5P193MB008317CB26D147DD042FD98A8CF70%40AM5P193MB0083.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: How to fetch data from sql server and display on django web pages

2018-02-11 Thread PASCUAL Eric
Hi Amit,


There is no "Django Web page" as you write in your message, but Web pages of 
the application built on top of the Django framework. Hence how to display data 
depends on how the Web pages of *your* application are designed.


Second point, one of the roles of Django is to isolate the application 
developer from the raw SQL requests needed to store and retrieve data from the 
underlying data base. This is called an ORM (object relational mapping) and it 
is one of the keystones of the Django framework. The benefit from this is that 
you don't have to deal with SQL requests (at least for the vast majority of the 
situations), but to specify the data model of the application as a collection 
of classes and relations between them. Django tools will take care of creating 
the relational database first, and then translate under the hood the object 
oriented interactions you make with your model into the corresponding SQL 
requests.


I've the feeling that you have not fully understood what Django is, what Django 
does and how to write a Django application. So, take no offense, but have you 
read (and understood) at least the introduction (including tutorials) 
documentation of Django ?


What is exactly the context of your project, what is it supposed to do,... ? 
The way you are presenting it, it sounds a bit like a student homework. Maybe 
it's not, but...


Best regards.


Eric

From: django-users@googlegroups.com  on behalf 
of Amit Kadivar 
Sent: Sunday, February 11, 2018 6:37:28 AM
To: Django users
Subject: How to fetch data from sql server and display on django web pages

Please Help me.
How to fetch data from sql server and display them on django web pages through 
nginx web server..




--
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/b5577524-e67d-465f-bb49-e54bca92c88b%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/AM5P193MB00835F3E9901536A3FF319C28CF00%40AM5P193MB0083.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: How to install and use Django

2018-02-10 Thread PASCUAL Eric
Hi,


As a satisfied user, without any connection with JetBrain corp., and after 
having worked for several years before with Eclipse/PyDev, my feeling is that 
PyCharm is the best IDE of the moment for "non-toys" Python + framework 
projects.


Beware that if you want to benefit from the Web or scientific frameworks full 
support, you'll need the Pro (not free) version. But even if you'll have to pay 
for it, its price is really low for personal licenses (and even for enterprise 
ones), and the renewal fee drops every year, down to 53% after the 3rd year.


Best regards


Eric PASCUAL


From: django-users@googlegroups.com  on behalf 
of Jani Tiainen 
Sent: Friday, February 9, 2018 7:32:00 AM
To: django-users@googlegroups.com
Subject: Re: How to install and use Django


Hi,

There is not actual IDE for Django, IDEs like Visual Studio, PyCharm, PyDev.

Also some editors like Vim, Emacs, VSCode, Atom, Textmate do have support for 
Python at some extent.

Do the  official tutorial [1] or if you find that official tutorial is too 
packed Django Girls [2] do have excellent tutorial that goes in depth what you 
need to do to get Django apps up and running.

[1] https://docs.djangoproject.com/en/2.0/intro/
[2] https://tutorial.djangogirls.org/en/

On 8.2.2018 12.14, Vismaad Tamber wrote:
Hi

I am new to Django. can anyone please help me with installation and 
starting a project. Does Django have IDE like dreamweaver or Visual studio to 
design a website?
I have installed Python 3.6 on my Windows machine. Also I have downloaded and 
installed Django files at location 
C:\Users\Vismaad\Documents\Django-2.0.2\build\lib\django.

   I have no idea how to move ahead. What are Django-admin-tools?

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/1f7aced7-72b8-4b7c-baee-ec891dc0509d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Jani Tiainen

--
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/78b69e58-57ec-4639-4248-cddca83b304a%40gmail.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/AM5P193MB0083AD8ED2BBB382B41EF4FB8CF10%40AM5P193MB0083.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: How to install and use Django

2018-02-10 Thread PASCUAL Eric
Hi,


If virtualenv is to be avoided (which I do not recommend anyway, especially for 
a newbie, since it protects him from breaking his Python system installation), 
my advice would be to go with:


$ python setup.py install --user


This way only the user's private environment is modified, and if anything goes 
wrong the normal behavior of the system can be restored by deleting the 
relevant tree under $HOME/.local (or its equivalent for non Linux contexts).


IMHO, suggesting a sudo based approach to a newbie (and even to a confirmed) 
user is an open door to system mess.


Anyway, virtualenv worth the investment learning how to use it. I have been 
used to deploy packages in Python system libs on production systems, and ran 
into problem at a time. Since then, and even when there is only one Python app 
running on the box, I have always deployed under virtualenvs and fell much 
better now.


Note : To be honest, this is not fully true currently, because I've switched to 
Docker based deployment for new projects, which eliminates all this libs 
conflicts hassles and ensure me that things run the same on my local staging 
env and on the production server. This is of course not the only benefit, but 
it solves this specific problem. For true production application class 
projects, I would recommend investing a bit in this direction.


Just my $0.02


Best regards


Eric


From: django-users@googlegroups.com  on behalf 
of Etienne Robillard 
Sent: Friday, February 9, 2018 9:37:02 PM
To: James Farris
Cc: django-users@googlegroups.com
Subject: Re: How to install and use Django

i found that the best way to confuse a newbie python/django programmer
is to invite him/her to use virtualenv.

Virtualenv is absolutely NOT required for properly running django in
development or production mode.

a most flexible approach is to install django in development mode:

$ cd /path/to/django

$ sudo python setup.py develop --prefix=/usr/local

HTH,

Etienne


Le 2018-02-09 à 13:12, James Farris a écrit :
> I highly recommend installing virtualenv and virtualenvwrapper. This will 
> reduce the stress of creating a bunch of unnecessary modules on your computer 
> and contain each project you create in a separate environment. For example 
> you wouldn’t necessarily want to install Django globally but rather for a 
> specific project your working on. That’s where virtualenv comes in.
>
> I also recommend going through the Django Book. It walks you through an app 
> that uses a lot of what Django has to offer: https://djangobook.com
>
> Also go through the Writing your first Django app in the Django docs: 
> https://docs.djangoproject.com/en/2.0/intro/tutorial01/
>
> I use PyCharm, because it has great auto complete and debugging.
>
> Other references mentioned above are below.
>
> Django apps: https://docs.djangoproject.com/en/2.0/ref/applications/
> Homebrew: https://brew.sh/
> Virtualenv: https://virtualenv.pypa.io/en/stable/
> Virtualenvwrapper: 
> https://virtualenvwrapper.readthedocs.io/en/latest/install.html
>

--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

--
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/394be6a7-15a1-4328-90cf-b1385ac34bef%40yandex.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/AM5P193MB0083C6948FA5DED20EB38EB08CF10%40AM5P193MB0083.EURP193.PROD.OUTLOOK.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Django Templates and Conditional CSS classes

2017-11-11 Thread PASCUAL Eric
Hi,


Since it is static (i.e. never modified), the CSS classes dictionary (statemap) 
could be extracted from the function and promoted as a module global variable, 
to avoid it being reconstructed each time the filter is invoked.


This will not cut the processing time in half, but small streams make big 
rivers :)


Eric

From: django-users@googlegroups.com  on behalf 
of treyd 
Sent: Saturday, November 11, 2017 20:49
To: Django users
Subject: Re: Django Templates and Conditional CSS classes

Omar (and everybody else who responded),

Thanks for that ideas and putting a method on the model to return the 
appropriate CSS class based on the state.  I think that would be the cleanest 
solution if I am going to bite the bullet and put this template-specific logic 
on the model.

It got me thinking, though, and it might be a better place to handle this in 
the view.  I tried that and I got it to work by extending DetailView into a 
custom view modified the context before rendering the template.  This removed 
the template logic, but I ran into another issue when I am trying to access 
other models associated with the model I'm looking at in the DetailView and 
handling their state label styling, so I scrapped that approach.

I did some more research and the solution I finalized on was a custom template 
filter that would read the state and convert it to the appropriate CSS class, 
e,g,:

{{ myobject.state 
}}

To do this, I followed the Django Custom Template Tags 
How-To and 
came up with this:
from django import template

register = template.Library()


@register.filter
def state_css_class(value):
"""returns appropriate bootstrap label class for states"""
statemap = {
'Scheduled': 'label-default',
'Provisioning': 'label-primary',
'Active': 'label-success',
'Deleting': 'label-primary',
'Ended': 'label-info',
'Unprovisioned': 'label-default',
'Building': 'label-primary',
'Deleted': 'label-primary',
'Error': 'label-danger'
}
try:
return statemap[value]
except KeyError:
return 'label-default'


I like this solution the best because it keeps template logic in/near the 
template layer, I can add new state renderings easily, and I can extend it to 
handle states for multiple model types (i have more than one stateful model in 
my project).

I hope someone else finds this useful!  Thanks again all for the discussion.

On Saturday, November 11, 2017 at 10:18:25 AM UTC-5, Omar Helal wrote:
Hi treyd,
I think idea of updating the model and storing it in the db is a bit overkill, 
however you could create an @propery on the model that will do that logic for 
you and return the css class for you.
e.g.
@property
def css_class(self):
  if self.state is SUCHANDSUCH:
 return "label-soandso"

and so in the template you can do what Vijay recommended but without storing 
anything you don't need in the database.

Good luck with going Angular, it plays well with Django!

On Saturday, 11 November 2017 09:50:38 UTC+11, treyd wrote:
Thanks, all, for the info.  Looks like the best way to clean this up is to make 
the model have some knowledge of the CSS class I want to use and make a method 
to get it.  I like that, but I was unsure about sticking view information into 
the model.  Probably the best solution is javascript logic in the browser, 
which I'll get to.

On Friday, November 10, 2017 at 5:45:02 PM UTC-5, Vijay Khemlani wrote:
You can also add a "state_css_class" (or something) method to your object class 
and just call

...

the method should be quite simple

On Fri, Nov 10, 2017 at 7:01 PM, Adam Simon  wrote:

 You can pass the class from either the model or the view into the template. 
For example, you can assign a class to a button with a variable:

<|button>

And then the class would have to be defined in your style somewhere

On Fri, Nov 10, 2017 at 1:37 PM treyd  wrote:
At some point I plan on figuring out how to do more intelligent front-end 
in-browser stuff (Angular, etc) which yeah would definitely help me here but I 
was wondering if there was a Django-only way of doing this.


On Friday, November 10, 2017 at 3:51:09 PM UTC-5, Adam wrote:

Are you open to using JavaScript in the front end? It would make it really easy
On Fri, Nov 10, 2017 at 12:40 PM treyd  wrote:
Hello,

I am trying to render a model field in a django template, and, based on the 
value of the field, I want to specify a different CSS class.  Right now, my 
solution is this:

{{ myobject.state }}

This works, but seems like a really ugly solution and a bunch of logic in the 
template.  Is there a better way of doing this?  My thought was to put the 
class names as another field in the model, but that seems like it would violate 
the MVC (or MVT) separation. Any ideas?

Thanks in advance,
treyd

--
You received this message because you are s

RE: do i always have to reload/return render a page to show the errors? if i press go back on browser, i see screens with the error message

2017-10-31 Thread PASCUAL Eric
Hello
Sorry or I misunderstood your problem but what about using the required field 
attribute ? It will make such controls and messages be handled directly on the 
client side. 
Best regards. 

Eric PASCUAL

Centre Scientifique et Technique du Bâtiment
290 route des Lucioles
06560 SOPHIA ANTIPOLIS
http://www.cstb.fr



From: django-users@googlegroups.com [django-users@googlegroups.com] on behalf 
of fábio andrews rocha marques [fabioandrewsrochamarq...@gmail.com]
Sent: Tuesday, October 31, 2017 00:46
To: Django users
Subject: do i always have to reload/return render a page to show the errors? if 
i press go back on browser, i see screens with the error message

Let's say i have a "register a new user" View and on this page, when the user 
forgets to inform a password or a username, i show a message to him on the same 
page saying "you forgot the password". The way i do this is by doing this(on my 
View.py in a function called cadastrarprofessor):

nomeusuario = request.POST['usuario'] #username
nomesenha = request.POST['senha'] #password
nomeemail = request.POST['email'] #email

if not nomeusuario:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe um usuário", 'nomeemailcadastro':nomeemail, 
'nomesenhacadastro':nomesenha})
elif not nomesenha:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe uma senha", 'nomeemailcadastro':nomeemail, 
'nomeusuariocadastro':nomeusuario})
elif not nomeemail:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe um email", 'nomesenhacadastro':nomesenha, 

'nomeusuariocadastro':nomeusuario})

And my template for this page(cadastro.html) is like this:

Cadastro

{% csrf_token %}
Usuário: 
{% if nomeusuariocadastro %}

{% else %}

{% endif %}


... (DO THE SAME TO SENHA/PASSWORD AND EMAIL)





{% csrf_token %}

{% if cadastrorealizadocomsucesso is True %}cadastro realizado com 
sucesso!{% endif %}
{% if error_message %}{{ error_message }}{% endif %}

So, every time the user forgets to mention a username or email or password in 
this screen, i use render to redirect the user to the same page but this time 
displaying a error_message. Let's say he did forget to fill the textfield with 
a username... he goes back to the same page and sees the error message. After 
that, let's say everything is right and he finally registers a new user, he 
sees "cadastro realizado com sucesso"(sucessfully registered new user) and 
stays on the same page. But when he goes back a page(pressing "back" on the 
browser), instead of going back to the page before the cadastro.html, he goes 
back to the same page cadastro.html but displaying the error message for the 
"you forgot to mention your username". I don't want him to go back to the same 
page with error message, i want to make him go back to my main menu.
Is there a better approach to display error messages on the same page instead 
of using return render like this:
return render(request,'cadastro.html',{'cadastrorealizadocomsucesso': False, 
'error_message': "informe um usuário", 
'nomeemailcadastro':nomeemail,'nomesenhacadastro':nomesenha})
?


--
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/3f70cd29-9edc-4272-a27e-534ee7f1e1a2%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/b7a39000e7b344c78b85d12d2e703d60%40Lizherel.cstb.local.
For more options, visit https://groups.google.com/d/optout.