Re: Recipe to upgrade to Python 3.x on Ubuntu 12.04 and 14.04

2016-09-07 Thread Mike Dewhirst

On 7/09/2016 6:49 PM, James Schneider wrote:


On Sep 6, 2016 10:44 PM, "Mike Dewhirst" > wrote:

>
> I'm looking for a step-by-step system admin recipe to get away from 
Python 2.7 because unicode on 2.7 is doing my head in. This is ugly I 
know but that's how it is.

>
> Staging server is Ubuntu 12.04on local hardwarewith Python 2.7 and 
it runs Apache2 and mod_wsgi. It serves Django, Subversion, Buildbot, 
Trac and Samba (local fileserver for Windows PCs) all of which need to 
keep running after the upgrade. I can take them all down temporarily 
when required.

>
> Production server is Ubuntu 14.04 with Python 2.7 and runs Apache2 
and mod_wsgi. It is dedicated to serving Django alone. It is a VM in a 
private cloud.

>

Argh...different platform OS versions for staging and production!



To be honest that never bothered me although it makes sense in 
hindsight. By the time we went into production Ubuntu had released 14.04 
and we didn't have any pressing incentive to move staging forward. We 
still have until mid-next year before support evaporates.


I suppose that isn't the worst thing as it relates to Python 2.7, 
since things should stay synced.


Python 3 development is moving much faster, so you do have different 
3.X versions available between Ubuntu LTS releases. This is 
problematic with your current deployment, especially since a few 
changes in 3.2 broke code compatibility as it relates to Unicode 
strings, ironically.




There is a deadsnakes repo which would let us keep identical pythons on 
any current Ubuntu system. And having done some research on this I was 
expecting advice to move in that direction. I would impose 3.5 on all 
systems if we go there.


The only way to keep the Python versions the same would be to compile 
a specific version yourself on both boxes (although someone may 
provide a back port).The real 'gotcha' here is WSGI/Apache. Mod_wsgi 
has to be compiled against the version of Python that you plan to use. 
Obviously it can also be compiled in along with python itself, but now 
we've started down a long unmanageable road of security updates and 
custom integration. This is why package management was invented; so 
that I don't have to think about keeping things up to date, and just 
rely on people smarter than me to provide those updates in an 
automated process. Well...I still have to tell the system to update, 
but everything else is automated.




This is where the nightmares begin. I don't mind compiling the right 
bits and pieces but it isn't something I have deliberately done before. 
I have totally relied on package management to date. Again, honesty 
compels me to say it is daunting.


I'm only referring to the base python (and the root pip3) installation 
here. Pip3 and virtualenv should be utilized for everything else.




Yes. How does Apache decide which Python to use?

> At this stage my fallback plan is to build a new staging server on 
Ubuntu 16.04 on local hardware and reinstall Subversion, Buildbot, 
Trac and Samba. That's a lot of tasks I don't have the time/brainspace 
to tackle just yet.

>

If a solid back port for a common version of python (and mod_wsgi) 
between staging and prod is not available, I'd go this route, and 
upgrade everything to the same version.




Looks like the safest bet. I hate the fact that I have to focus on the 
OS and infrastructure instead of the Django side of things. Might leave 
some services on the old machine and just move the staging server to 16.04.


> Does anyone have any suggested strategies or advice? The sole 
objective is to retire Python 2.7. There are no Django third party app 
requirements for Python 2.7. Haven't looked at Buildbot or Trac yet.

>

Getting your internal tools like Trac migrated should be a lower 
priority than your application code.


Unless there is some whiz-bang feature only available for Py3, you'll 
probably be on 2.7 for those for a while just because of the 
complexity integration pieces you mentioned. That may be problematic 
if the same WSGI processes handle all of these integration apps.




I think separating the servers into staging and "the rest" will have to 
suffice.


It seems like folks are reasonably happy with Py 3.4, but 3.5 has a 
bunch of async improvements that Django is or will soon be taking 
advantage of for Channels.




Agreed. I wouldn't go to this trouble without implementing 3.5. All 
development is done with 3.5 and all testing is on 2.7.


You may also want to consider building in a configuration manager such 
as Ansible or Salt stack. Once set up, you can deploy multiple staging 
and prod servers with a couple commands. With the right planning, that 
could potentially work across major Ubuntu versions as an upgrade path.




Do I need a PhD to do that?



Probably won't save you time up front, but it definitely will next 
time this comes around, with the added bonus of a near instantaneous 
recovery 

Re: Django group email in spam

2016-09-07 Thread sylvain_grodes
Same problem here, I have to check my spam and unset the spam flag.



Le vendredi 2 septembre 2016 02:12:18 UTC-4, Lachlan Musicman a écrit :
>
> Hey,
>
> I've been seeing a lot of Django group email going into my spam folder 
> over the last 48 hours.
>
> Have there been any changes to the group that may have caused this?
>
> cheers
> L.
> --
> The most dangerous phrase in the language is, "We've always done it this 
> way."
>
> - Grace Hopper
>

-- 
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/de7b0239-ff49-4c83-acb8-53308a1178e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: multiple django installation in one server

2016-09-07 Thread Luis Zárate
Take a look
http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
,
You can do this steps for ever  django project in the same server




2016-09-07 7:28 GMT-06:00 miarisoa sandy :

> Hi guys,
>
> I hope you are doing fine.
> I have googled it but no fruitful results.
> I am a newbie in django and I wonder what is the number maximum django
> that I can install in one server??
> I have a lot of projects that I would like to check with django ( one
> project -> one django) to avoid some confusion with each project (PHP
> project).
> Or what is the best way for me??
>
> The server is: Ubuntu 12.04, intel core i5 3.2Ghz, 4Go of RAM
>
> Waiting to hear from you, thanks for your help.
>
> Best
>
>
> --
> 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/33008438-92bf-4283-ab52-b6909eb81193%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyMbnbixBovR10kTJgyHiW70BT4ijLu_boyJLLsftm3EOg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to split value where is comma ?

2016-09-07 Thread ludovic coues
That look a lot like a csv file. I strongly suggest you take a look at
[1] and [2]. It should let you work with your data as if it's a list
of dict. Pretty handy.

If all you want is to add a newline after each comma, I suggest to use replace.
>>> print("1,2,3".replace(",", ",\n"))
1,
2,
3

[1] https://docs.python.org/3/library/csv.html#csv.DictReader
[2] https://docs.python.org/3/library/io.html#io.StringIO

2016-09-07 17:50 GMT+02:00 Asad ur Rehman :
> Here is my view.py
>
> import os.path
> import commands
>
> def call_report(request):
>
> a = commands.getstatusoutput('/usr/local/freeswitch/bin/fs_cli -x "show
> calls"')
> return HttpResponse(a)
>
>
> When i run this command it gives output which you can see...
>
>
> 0uuid,direction,created,created_epoch,name,state,cid_name,cid_num,ip_addr,dest,presence_id,presence_data,callstate,callee_name,callee_num,callee_direction,call_uuid,hostname,sent_callee_name,sent_callee_num,b_uuid,b_direction,b_created,b_created_epoch,b_name,b_state,b_cid_name,b_cid_num,b_ip_addr,b_dest,b_presence_id,b_presence_data,b_callstate,b_callee_name,b_callee_num,b_callee_direction,b_sent_callee_name,b_sent_callee_num,call_created_epoch
> 7135c05c-7511-11e6-a09e-89a1f4981d2c,outbound,2016-09-07
> 11:40:45,1473262845,sofia/external/12036325207,CS_EXECUTE,Outbound
> Call,12036325207,,12036325207,,,ACTIVE,9047125683,9047125683,RECV,7135c05c-7511-11e6-a09e-89a1f4981d2c,vb-pmedia,
> 75a9d3ee-7511-11e6-a115-89a1f4981d2c,outbound,2016-09-07
> 11:40:53,1473262853,sofia/external/12036325259,CS_EXECUTE,Outbound
> Call,12036325259,,12036325259,,,ACTIVE,9047125683,9047125683,RECV,75a9d3ee-7511-11e6-a115-89a1f4981d2c,vb-pmedia,
> 7841c6c0-7511-11e6-a139-89a1f4981d2c,outbound,2016-09-07
> 11:40:57,1473262857,sofia/external/16189973135,CS_EXECUTE,Outbound
> Call,16189973135,,16189973135,,,ACTIVE,3473788006,3473788006,RECV,7841c6c0-7511-11e6-a139-89a1f4981d2c,vb-pmedia,
> 78582a82-7511-11e6-a141-89a1f4981d2c,outbound,2016-09-07
> 11:40:57,1473262857,sofia/external/16185392123,CS_EXECUTE,Outbound
> Call,16185392123,,16185392123,,,ACTIVE,3473788006,3473788006,RECV,78582a82-7511-11e6-a141-89a1f4981d2c,vb-pmedia,
> 79eda1ec-7511-11e6-a161-89a1f4981d2c,outbound,2016-09-07
> 11:41:00,1473262860,sofia/external/12037584114,CS_EXECUTE,Outbound
> Call,12037584114,,12037584114,,,ACTIVE,3473788006,3473788006,RECV,79eda1ec-7511-11e6-a161-89a1f4981d2c,vb-pmedia,
> 7a02bb90-7511-11e6-a169-89a1f4981d2c,outbound,2016-09-07
> 11:41:00,1473262860,sofia/external/13346775290,CS_EXECUTE,Outbound
> Call,13346775290,,13346775290,,,ACTIVE,3473788006,3473788006,RECV,7a02bb90-7511-11e6-a169-89a1f4981d2c,vb-pmedia,
> 7a1fa002-7511-11e6-a179-89a1f4981d2c,outbound,2016-09-07
> 11:41:00,1473262860,sofia/external/15154483189,CS_EXECUTE,Outbound
> Call,15154483189,,15154483189,,,ACTIVE,3473788006,3473788006,RECV,7a1fa002-7511-11e6-a179-89a1f4981d2c,vb-pmedia,
> 7a20d864-7511-11e6-a181-89a1f4981d2c,outbound,2016-09-07
> 11:41:00,1473262860,sofia/external/12036325257,CS_EXECUTE,Outbound
> Call,12036325257,,12036325257,,,ACTIVE,9047125683,9047125683,RECV,7a20d864-7511-11e6-a181-89a1f4981d2c,vb-pmedia,
> 7a354cf4-7511-11e6-a191-89a1f4981d2c,outbound,2016-09-07
> 11:41:00,1473262860,sofia/external/13348725798,CS_EXECUTE,Outbound
> Call,13348725798,,13348725798,,,ACTIVE,9047125683,9047125683,RECV,7a354cf4-7511-11e6-a191-89a1f4981d2c,vb-pmedia,
> 7e90e128-7511-11e6-a1d4-89a1f4981d2c,outbound,2016-09-07
> 11:41:07,1473262867,sofia/external/13345880337,CS_EXECUTE,Outbound
> Call,13345880337,,13345880337,,,ACTIVE,9047125683,9047125683,RECV,7e90e128-7511-11e6-a1d4-89a1f4981d2c,vb-pmedia,
> 7e9c3514-7511-11e6-a1e8-89a1f4981d2c,outbound,2016-09-07
> 11:41:08,1473262868,sofia/external/12036325256,CS_EXECUTE,Outbound
> Call,12036325256,,12036325256,,,ACTIVE,9047125683,9047125683,RECV,7e9c3514-7511-11e6-a1e8-89a1f4981d2c,vb-pmedia,
> 7f3cdc62-7511-11e6-a1ff-89a1f4981d2c,outbound,2016-09-07
> 11:41:09,1473262869,sofia/external/13344992844,CS_EXECUTE,Outbound
> Call,13344992844,,13344992844,,,ACTIVE,9047125683,9047125683,RECV,7f3cdc62-7511-11e6-a1ff-89a1f4981d2c,vb-pmedia,
> 82179454-7511-11e6-a228-89a1f4981d2c,outbound,2016-09-07
> 11:41:13,1473262873,sofia/external/16185392157,CS_EXECUTE,Outbound
>
>
> But i want to get output like this
>
>
> 

How to split value where is comma ?

2016-09-07 Thread Asad ur Rehman
Here is my view.py

import os.path
import commands

def call_report(request):
 
a = commands.getstatusoutput('/usr/local/freeswitch/bin/fs_cli -x "show 
calls"')
return HttpResponse(a)


When i run this command it gives output which you can see...


0uuid,direction,created,created_epoch,name,state,cid_name,cid_num,ip_addr,dest,presence_id,presence_data,callstate,callee_name,callee_num,callee_direction,call_uuid,hostname,sent_callee_name,sent_callee_num,b_uuid,b_direction,b_created,b_created_epoch,b_name,b_state,b_cid_name,b_cid_num,b_ip_addr,b_dest,b_presence_id,b_presence_data,b_callstate,b_callee_name,b_callee_num,b_callee_direction,b_sent_callee_name,b_sent_callee_num,call_created_epoch
 
7135c05c-7511-11e6-a09e-89a1f4981d2c,outbound,2016-09-07 
11:40:45,1473262845,sofia/external/12036325207,CS_EXECUTE,Outbound 
Call,12036325207,,12036325207,,,ACTIVE,9047125683,9047125683,RECV,7135c05c-7511-11e6-a09e-89a1f4981d2c,vb-pmedia,
 
75a9d3ee-7511-11e6-a115-89a1f4981d2c,outbound,2016-09-07 
11:40:53,1473262853,sofia/external/12036325259,CS_EXECUTE,Outbound 
Call,12036325259,,12036325259,,,ACTIVE,9047125683,9047125683,RECV,75a9d3ee-7511-11e6-a115-89a1f4981d2c,vb-pmedia,
 
7841c6c0-7511-11e6-a139-89a1f4981d2c,outbound,2016-09-07 
11:40:57,1473262857,sofia/external/16189973135,CS_EXECUTE,Outbound 
Call,16189973135,,16189973135,,,ACTIVE,3473788006,3473788006,RECV,7841c6c0-7511-11e6-a139-89a1f4981d2c,vb-pmedia,
 
78582a82-7511-11e6-a141-89a1f4981d2c,outbound,2016-09-07 
11:40:57,1473262857,sofia/external/16185392123,CS_EXECUTE,Outbound 
Call,16185392123,,16185392123,,,ACTIVE,3473788006,3473788006,RECV,78582a82-7511-11e6-a141-89a1f4981d2c,vb-pmedia,
 
79eda1ec-7511-11e6-a161-89a1f4981d2c,outbound,2016-09-07 
11:41:00,1473262860,sofia/external/12037584114,CS_EXECUTE,Outbound 
Call,12037584114,,12037584114,,,ACTIVE,3473788006,3473788006,RECV,79eda1ec-7511-11e6-a161-89a1f4981d2c,vb-pmedia,
 
7a02bb90-7511-11e6-a169-89a1f4981d2c,outbound,2016-09-07 
11:41:00,1473262860,sofia/external/13346775290,CS_EXECUTE,Outbound 
Call,13346775290,,13346775290,,,ACTIVE,3473788006,3473788006,RECV,7a02bb90-7511-11e6-a169-89a1f4981d2c,vb-pmedia,
 
7a1fa002-7511-11e6-a179-89a1f4981d2c,outbound,2016-09-07 
11:41:00,1473262860,sofia/external/15154483189,CS_EXECUTE,Outbound 
Call,15154483189,,15154483189,,,ACTIVE,3473788006,3473788006,RECV,7a1fa002-7511-11e6-a179-89a1f4981d2c,vb-pmedia,
 
7a20d864-7511-11e6-a181-89a1f4981d2c,outbound,2016-09-07 
11:41:00,1473262860,sofia/external/12036325257,CS_EXECUTE,Outbound 
Call,12036325257,,12036325257,,,ACTIVE,9047125683,9047125683,RECV,7a20d864-7511-11e6-a181-89a1f4981d2c,vb-pmedia,
 
7a354cf4-7511-11e6-a191-89a1f4981d2c,outbound,2016-09-07 
11:41:00,1473262860,sofia/external/13348725798,CS_EXECUTE,Outbound 
Call,13348725798,,13348725798,,,ACTIVE,9047125683,9047125683,RECV,7a354cf4-7511-11e6-a191-89a1f4981d2c,vb-pmedia,
 
7e90e128-7511-11e6-a1d4-89a1f4981d2c,outbound,2016-09-07 
11:41:07,1473262867,sofia/external/13345880337,CS_EXECUTE,Outbound 
Call,13345880337,,13345880337,,,ACTIVE,9047125683,9047125683,RECV,7e90e128-7511-11e6-a1d4-89a1f4981d2c,vb-pmedia,
 
7e9c3514-7511-11e6-a1e8-89a1f4981d2c,outbound,2016-09-07 
11:41:08,1473262868,sofia/external/12036325256,CS_EXECUTE,Outbound 
Call,12036325256,,12036325256,,,ACTIVE,9047125683,9047125683,RECV,7e9c3514-7511-11e6-a1e8-89a1f4981d2c,vb-pmedia,
 
7f3cdc62-7511-11e6-a1ff-89a1f4981d2c,outbound,2016-09-07 
11:41:09,1473262869,sofia/external/13344992844,CS_EXECUTE,Outbound 
Call,13344992844,,13344992844,,,ACTIVE,9047125683,9047125683,RECV,7f3cdc62-7511-11e6-a1ff-89a1f4981d2c,vb-pmedia,
 
82179454-7511-11e6-a228-89a1f4981d2c,outbound,2016-09-07 
11:41:13,1473262873,sofia/external/16185392157,CS_EXECUTE,Outbound 


But i want to get output like this


0uuid,direction,created,created_epoch,name,state,cid_name,cid_num,ip_addr,dest,presence_id,presence_data,callstate,callee_name,callee_num,callee_direction,call_uuid,hostname,sent_callee_name,sent_callee_num,b_uuid,b_direction,b_created,b_created_epoch,b_name,b_state,b_cid_name,b_cid_num,b_ip_addr,b_dest,b_presence_id,b_presence_data,b_callstate,b_callee_name,b_callee_num,b_callee_direction,b_sent_callee_name,b_sent_callee_num,call_created_epoch
 
7135c05c-7511-11e6-a09e-89a1f4981d2c,outbound,2016-09-07 
11:40:45,1473262845,sofia/external/12036325207,CS_EXECUTE,Outbound 
Call,12036325207,,12036325207,,,ACTIVE,9047125683,9047125683,RECV,7135c05c-7511-11e6-a09e-89a1f4981d2c,vb-pmedia,
 
75a9d3ee-7511-11e6-a115-89a1f4981d2c,outbound,2016-09-07 11:40:53,
1473262853,
sofia/external/1203632525,CS_EXECUTE,
Outbound Call,
12036325259,
,12036325259,
,
,ACTIVE,
9047125683,
9047125683,
RECV,
75a9d3ee-7511-11e6-a115-89a1f4981d2c,

CSRF_COOKIE_SECURE and SESSION_COOKIE_SECURE to True when terminating SSL on load balancer

2016-09-07 Thread Camilo Torres
Hi.

As you are currently using HTTPS, setting these to true make sense.

These settings are used by the browser to ensure encripted cookies. It does not 
matter if you are using haproxy with ssl termination.

Camilo Torres.

-- 
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/265e1900-da24-435a-a64a-77bc1dca0410%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: multiple django installation in one server

2016-09-07 Thread Asad Jibran Ahmed
Hi,
 I have a similar setup for my projects. What I do is:

   1. Create a new virtual environment for the project (
   https://virtualenv.pypa.io/en/stable/). Virtual environments make sure
   that each project that you deploy can have it's own set of dependencies
   that do not conflict with the other projects.
   2. Install your required libraries in the virtual environment
   3. Use uwsgi in the Emperor mode to configure and run each app. Within
   the uwsgi config you can give it the virtual environment to use.

With this way I run multiple Django apps, each with different requirements,
on the same server without any issues. This involves a bit of
configuration, which may be daunting if this is the first time you're doing
this. If so, please do ask and I'm sure we can guide you further as well.

The number of projects that can be run on one server is very much dependent
on what kind of projects you are running, and the kind of traffic your
applications handle. My suggestion is to slowly add 1 or 2 projects at a
time and monitor the server to make sure it isn't overloaded. If not,
repeat. Otherwise get another server and setup the rest of the projects on
that.

Regards,

Asad Jibran Ahmed 
http://blog.asadjb.com

On Wed, Sep 7, 2016 at 5:28 PM, miarisoa sandy 
wrote:

> Hi guys,
>
> I hope you are doing fine.
> I have googled it but no fruitful results.
> I am a newbie in django and I wonder what is the number maximum django
> that I can install in one server??
> I have a lot of projects that I would like to check with django ( one
> project -> one django) to avoid some confusion with each project (PHP
> project).
> Or what is the best way for me??
>
> The server is: Ubuntu 12.04, intel core i5 3.2Ghz, 4Go of RAM
>
> Waiting to hear from you, thanks for your help.
>
> Best
>
>
> --
> 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/33008438-92bf-4283-ab52-b6909eb81193%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BYYaWc3DiJ_jsww38p8kDtfktaWN354V64WOKntXkTeRraktQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


multiple django installation in one server

2016-09-07 Thread miarisoa sandy
Hi guys,

I hope you are doing fine.
I have googled it but no fruitful results.
I am a newbie in django and I wonder what is the number maximum django that 
I can install in one server??
I have a lot of projects that I would like to check with django ( one 
project -> one django) to avoid some confusion with each project (PHP 
project).
Or what is the best way for me??

The server is: Ubuntu 12.04, intel core i5 3.2Ghz, 4Go of RAM

Waiting to hear from you, thanks for your help.

Best


-- 
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/33008438-92bf-4283-ab52-b6909eb81193%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


CSRF_COOKIE_SECURE and SESSION_COOKIE_SECURE to True when terminating SSL on load balancer

2016-09-07 Thread pjotr
Hi,

I use HAProxy as load balancer, where I also terminate the SSL. The traffic 
between HAProxy and the is unencrypted. I have force SSL enabled, so all 
requests with http will be redirected to https.

Question is, does it serve any good to have CSRF_COOKIE_SECURE 
and SESSION_COOKIE_SECURE set to True in settings? It doesn't make sense 
for me, but there might be some other reasons for using that!?

/Peter

-- 
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/a5d82347-5d4f-481f-8bc5-94be751f9f71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django.core.exceptions.FieldDoesNotExist but the field exists

2016-09-07 Thread Stefano Tranquillini
It seems that i missed a part while merging.

On Mon, Sep 5, 2016 at 5:55 PM, Michal Petrucha <
michal.petru...@konk.org> wrote:

> On Mon, Sep 05, 2016 at 08:44:55AM -0700, Stefano Tranquillini wrote:
> > Hello
> >
> > I've a problem syncing the db.
> >
> > I run the command: django-admin migrate
> >
> > System check identified some issues:
> > Operations to perform:
> >   Synchronize unmigrated apps: oauth2_provider, 
> >   Apply all migrations: admin, Synchronizing apps without
> migrations:
> >   Creating tables...
> > Running deferred SQL...
> >   Installing custom SQL...Running migrations:
> >   No migrations to apply.Traceback (most recent call last):
> >   File "/Users/stefano/.virtualenvs/prjrest/bin/django-admin", line 11,
> in 
> > sys.exit(execute_from_command_line())
> >   File "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-
> packages/django/core/management/__init__.py", line 354, in
> execute_from_command_line
> > utility.execute()
> >   File "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-
> packages/django/core/management/__init__.py", line 346, in execute
> > self.fetch_command(subcommand).run_from_argv(self.argv)
> >   File "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-
> packages/django/core/management/base.py", line 394, in run_from_argv
> > self.execute(*args, **cmd_options)
> >   File "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-
> packages/django/core/management/base.py", line 445, in execute
> > output = self.handle(*args, **options)
> >   File "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-
> packages/django/core/management/commands/migrate.py", line 208, in handle
> > changes = autodetector.changes(graph=executor.loader.graph)
> >   File "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-
> packages/django/db/migrations/autodetector.py", line 43, in changes
> > changes = self._detect_changes(convert_apps, graph)
> >   File "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-
> packages/django/db/migrations/autodetector.py", line 165, in
> _detect_changes
> > old_field = self.old_apps.get_model(app_label,
> old_model_name)._meta.get_field(field_name)
> >   File "/Users/stefano/.virtualenvs/prjrest/lib/python2.7/site-
> packages/django/db/models/options.py", line 554, in get_field
> > raise FieldDoesNotExist('%s has no field named %r' %
> (self.object_name, field_name))
> > django.core.exceptions.FieldDoesNotExist: CustomerKey has no field
> named u'customer_key_cipher_text'
> >
> > So, it seems that there are not migration, but still django complains
> for a
> > missing field.
> >
> > However in the model the field is there
> >
> >
> > class CustomerKey(models.Model):...
> > customer_key_cipher_text = Base64Field(default='')
> >
> > Any idea on what's the problem?
>
> According to the stack trace, this error happens when the autodetector
> is trying to get the model field from a previous state of the models,
> which is determined from the migration history, not the current model
> definitions.
>
> Have you by any chance made any changes to any of the existing
> migrations? I can imagine that this could happen if one of your
> migrations tries to make an AlterField operation on a field that
> hasn't been created in any of the preceding migrations.
>
> Good luck,
>
> Michal
>
> --
> 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/DFXLEJsIJUo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/20160905155543.GJ6601%40konk.org.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Stefano

-- 
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/CAPQ1%3DkBPen0Xu94GenX%3DJEAS%2BAMe3bb-%3DPJ2cRs%3DUsHqrb_4GQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Recipe to upgrade to Python 3.x on Ubuntu 12.04 and 14.04

2016-09-07 Thread James Schneider
On Sep 6, 2016 10:44 PM, "Mike Dewhirst"  wrote:
>
> I'm looking for a step-by-step system admin recipe to get away from
Python 2.7 because unicode on 2.7 is doing my head in. This is ugly I know
but that's how it is.
>
> Staging server is Ubuntu 12.04on local hardwarewith Python 2.7 and it
runs Apache2 and mod_wsgi. It serves Django, Subversion, Buildbot, Trac and
Samba (local fileserver for Windows PCs) all of which need to keep running
after the upgrade. I can take them all down temporarily when required.
>
> Production server is Ubuntu 14.04 with Python 2.7 and runs Apache2 and
mod_wsgi. It is dedicated to serving Django alone. It is a VM in a private
cloud.
>

Argh...different platform OS versions for staging and production!

I suppose that isn't the worst thing as it relates to Python 2.7, since
things should stay synced.

Python 3 development is moving much faster, so you do have different 3.X
versions available between Ubuntu LTS releases. This is problematic with
your current deployment, especially since a few changes in 3.2 broke code
compatibility as it relates to Unicode strings, ironically.

The only way to keep the Python versions the same would be to compile a
specific version yourself on both boxes (although someone may provide a
back port).The real 'gotcha' here is WSGI/Apache. Mod_wsgi has to be
compiled against the version of Python that you plan to use. Obviously it
can also be compiled in along with python itself, but now we've started
down a long unmanageable road of security updates and custom integration.
This is why package management was invented; so that I don't have to think
about keeping things up to date, and just rely on people smarter than me to
provide those updates in an automated process. Well...I still have to tell
the system to update, but everything else is automated.

I'm only referring to the base python (and the root pip3) installation
here. Pip3 and virtualenv should be utilized for everything else.

> At this stage my fallback plan is to build a new staging server on Ubuntu
16.04 on local hardware and reinstall Subversion, Buildbot, Trac and Samba.
That's a lot of tasks I don't have the time/brainspace to tackle just yet.
>

If a solid back port for a common version of python (and mod_wsgi) between
staging and prod is not available, I'd go this route, and upgrade
everything to the same version.

> Does anyone have any suggested strategies or advice? The sole objective
is to retire Python 2.7. There are no Django third party app requirements
for Python 2.7. Haven't looked at Buildbot or Trac yet.
>

Getting your internal tools like Trac migrated should be a lower priority
than your application code.

Unless there is some whiz-bang feature only available for Py3, you'll
probably be on 2.7 for those for a while just because of the complexity
integration pieces you mentioned. That may be problematic if the same WSGI
processes handle all of these integration apps.

It seems like folks are reasonably happy with Py 3.4, but 3.5 has a bunch
of async improvements that Django is or will soon be taking advantage of
for Channels.

You may also want to consider building in a configuration manager such as
Ansible or Salt stack. Once set up, you can deploy multiple staging and
prod servers with a couple commands. With the right planning, that could
potentially work across major Ubuntu versions as an upgrade path.

Probably won't save you time up front, but it definitely will next time
this comes around, with the added bonus of a near instantaneous recovery of
a dev/prod system build with little need for backups beyond your custom app
code and the play books for your config management.

Otherwise, I wouldn't push too hard to get off of 2.7 just for the sake of
moving to 3.X. Phase it out where it makes sense, or halt development for a
week while the infrastructure is upgraded/rebuilt end-to-end.

Backup, backup, backup...

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciUNRN663pkvuLr_beVtZWQovPrTFx%2Bg8a9FrpMAfYjtUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.