Re: How install django in windows

2013-11-15 Thread Swaroop Shankar V
Hello Anuradha,

If you do a google search there are lots of tutorials covering this
information all over net. Basically you first need to install python
version < 3. Install python pip.  Make sure that the windows environment is
properly configured.  Then from your cmd type pip install django. Django
should be installed.

The above steps are just an overview of the installation. If you require
more details i would suggest you checking out:
https://code.djangoproject.com/wiki/WindowsInstall

If you have an option to install Linux,  then I would suggest you to use
linux for django development. Its very easy to setup and configure django
on a linux than on a windows machine.

Thanks and Regards,
Swaroop Shankar V
On Nov 16, 2013 9:53 AM, "Anuradha Nair"  wrote:

> Hi,
>
> I am new to django and i want to install it in my windows system.
> Can any one give step by step instructions?
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/bc7fc27a-5429-42fd-8415-707bcd97831f%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGG6gSMuRtBTs0mDshaLgeJNhUAT6GEe%2BDk%2B0rzdgkv-7gyE8A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


How install django in windows

2013-11-15 Thread Anuradha Nair
Hi,

I am new to django and i want to install it in my windows system.
Can any one give step by step instructions?

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bc7fc27a-5429-42fd-8415-707bcd97831f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


order_by result of sum of fields computed from an annotate

2013-11-15 Thread J . C . Leitão
Hi there.

Consider the situation where you want to order_by a sum of two fields 
obtained from an annotation. This 
problem
 states 
it correctly, however, the solution is not working for me. 

For concreteness, consider the example:

Author.objects.annotate(first_date=Avg('all_books__published_date'),
   last_date=Avg('all_books__added_date'))\
 .extra(select = {'delta_time': 'last_date - 
first_date'},
  order_by=['-delta_time'])

Where:

- Book has a manyToMany relationship with Author and 'all_books' is the 
related_name from the book to the author.
- *_date are dates.

I.e. For each author, I'm computing the average time it takes for a book to 
be added (e.g. to a library) since the moment it was published.

This query is not correct as "(1054, "Unknown column 'last_date' in 'field 
list'")", which I suspect is because the field all_books is a ManyToMany.

The 
solution
 I 
found so far was an extra like this:

Author.objects.extra(
select = {'delta_time': 'AVG(all_books__added_date) - 
AVG(all_books__published_date)'},
order_by = ['-delta_time']
)

but in this case this is not working with the error ""Unknown column 
'all_books__added_date'", which I suspect is also because the field is a 
ManyToMany.

Any ideas on how to create this query?

Thanks,
Jorge

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/104ab2a3-17e7-4726-be87-0ac353d957ca%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


notifications PagSeguro

2013-11-15 Thread Ricardo Kamada
Hi.

I am using the api Rafael PagSeguro to do here.
And to a problem in the notification.
the URL is correct and accessible, and I'm not doing these tests on
localhost.
I put a print function .. but I can not see.
But I think that the code PagSeguro sends a POST is not coming ...
Can anyone help me?

https://github.com/mstrcnvs/djpg
http://pastebin.com/29NMmbgn

Ricardo

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJTdXTFnxVvHM3q3ngP-hHV4bAATA7uHHSsjybQWN_fK1oeYCg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django tables 2 with django-autocomplete-light

2013-11-15 Thread Mario Gudelj
I have used datatables js for editable tables. Look up datatables jQuery
and you'll find a nice demo and a code example of how to implement them.
They also provide Ajax post when you press enter key, so all you have to do
is to hook it into your django view. Writing on phone so can't supply links
and examples. Sorry
M
On 16/11/2013 8:26 AM,  wrote:

> I'm trying to populate a django table with autocomplete light so that the
> user can fill in data in the table, which would then be saved (the whole
> table is in a form tag).  I have the table working to display the existing
> data and I have the autocomplete working in model forms (well, a team
> member got that part working), but I don't know how to combine the two.
>  The docs are a bit of a mystery to me, but maybe if someone could at least
> point me in the right direction I'd greatly appreciate it.
>
> --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8f04a2a7-d511-4533-b0e9-9177c5437349%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHqTbjkqv6MfbC3WHQ1R2ePc7i1buO6hE7xdiPGr7DxX%3DH0GkA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Django tables 2 with django-autocomplete-light

2013-11-15 Thread pnichols104
I'm trying to populate a django table with autocomplete light so that the 
user can fill in data in the table, which would then be saved (the whole 
table is in a form tag).  I have the table working to display the existing 
data and I have the autocomplete working in model forms (well, a team 
member got that part working), but I don't know how to combine the two. 
 The docs are a bit of a mystery to me, but maybe if someone could at least 
point me in the right direction I'd greatly appreciate it.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8f04a2a7-d511-4533-b0e9-9177c5437349%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Streaming images with HttpResponse?

2013-11-15 Thread Tomas Ehrlich
Hi there,
I don't know if it's relevant, I've never used it, but the name sounds 
promising:

StreamingHttpResponse
https://docs.djangoproject.com/en/dev/ref/request-response/#streaminghttpresponse-objects

Cheers,
  Tom

Dne Fri, 15 Nov 2013 12:53:23 -0500
Javier Guerra Giraldez  napsal(a):

> On Fri, Nov 15, 2013 at 12:08 PM, Jorge Cardoso Leitão
>  wrote:
> > I believe that is not possible with Django views. Views are made for
> > request-response, i.e. the client sends a request, the view returns a
> > response, and that's it, end of connection.
> 
> 
> i think the WSGI standard does support it, by setting a generator
> instead of a string value as the response content.
> 
> the generator is a function that yield()s more content each time, so
> the HTTP response becomes a stream of data.
> 
> but i think you're right that Django doesn't support it.
> 


signature.asc
Description: PGP signature


Re: Streaming images with HttpResponse?

2013-11-15 Thread Javier Guerra Giraldez
On Fri, Nov 15, 2013 at 12:08 PM, Jorge Cardoso Leitão
 wrote:
> I believe that is not possible with Django views. Views are made for
> request-response, i.e. the client sends a request, the view returns a
> response, and that's it, end of connection.


i think the WSGI standard does support it, by setting a generator
instead of a string value as the response content.

the generator is a function that yield()s more content each time, so
the HTTP response becomes a stream of data.

but i think you're right that Django doesn't support it.

-- 
Javier

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFkDaoQaCYa%2BwGRKtZcjvY%3DyE-0%2Bz0THUMj%2BZOftZeykCREuNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Streaming images with HttpResponse?

2013-11-15 Thread Jorge Cardoso Leitão
I Alex.

I believe that is not possible with Django views. Views are made for
request-response, i.e. the client sends a request, the view returns a
response, and that's it, end of connection.

In your case, the server has a stream of data that you want to constantly
send to the client. This sounds like a standard problem for using
Websockets
.

Within Django, there are some
apps for
using Websockets, even though I don't know how websockets work well for
video.

Hope this helps,
Jorge




On Fri, Nov 15, 2013 at 5:15 PM, Alex Karargyris wrote:

> I have this simple app that I opens webcam and processes the frames using
> OpenCV. In my views.py I have the following code:
>
> def processImage():
>
> while True:
>
> rval, frame = settings.CAP.read()  //Read frames from webcam
> gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) //Make
> frame grayscale
> pil_img = Image.fromarray(gray)
>
> response = HttpResponse(mimetype="image/png")
> pil_img.save(response, "PNG")
>
> return response
>
> Although there is a while loop the function runs only once because it is
> broken by "return response". How could I change the code to make it run
> constantly?
>
>
>  --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a13fe785-83ec-4a18-8377-090bdeda279d%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOYPqDAB1HiW9PLVngYeUxqOF365-QE5bEe9yjLF2xJkp_7X6w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: mod_wsgi setup

2013-11-15 Thread Fred Stluka

tino,

Didn't need the WSGIPythonHome setting in Apache, eh?
Interesting...

--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.


On 11/15/13 11:24 AM, tino wrote:

Thank you Fred for your help.

Finally I got it working. I tried different things and this is how my 
files looks  now.


spark.wsgi

=

import os
import sys
sys.stdout = sys.stderr
# Add the virtual Python environment site-packages directory to the path
import site
site.addsitedir('/var/www/html/virtualenv/lib/python2.7/site-packages')

#If your project is not on your PYTHONPATH by default you can add the 
following

sys.path.append('/var/www/html/djangosites/spark')
os.environ['DJANGO_SETTINGS_MODULE'] = 'spark.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

==

Apache entries

==

WSGIScriptAlias / /var/www/html/djangosites/spark.wsgi

WSGIDaemonProcess spark processes=5 threads=15 display-name=%{GROUP}

WSGIProcessGroup spark

WSGIApplicationGroup %{GLOBAL}

WSGISocketPrefix /var/run/wsgi



On Friday, November 15, 2013 3:04:58 PM UTC+5:30, tino wrote:

Hello,

I am trying to setup a python 2.7 + Django + virtualenv + mod_wsgi
environment in my centos 6.3 server to run my python application
through apache.
But I am getting internal error while trying to access the
application through apache. The error log shows the following.


[Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54]
mod_wsgi (pid=20361): Target WSGI script
'/var/www/html/djangosites/spark.wsgi' cannot be loaded as Python
module.
[Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54]
mod_wsgi (pid=20361): Exception occurred processing WSGI script
'/var/www/html/djangosites/spark.wsgi'.
Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54]
ImproperlyConfigured: Requested setting DEBUG, but settings are
not configured. You must either define the environment variable
DJANGO_SETTINGS_MODULE or call settings.configure() before
accessing settings.



It is working fine when running as a test server.

==
(virtualenv)[root@lampserver spark]# python manage.py runserver
0.0.0.0:8080 
Validating models...

0 errors found
November 15, 2013 - 09:15:19
Django version 1.6, using settings 'spark.settings'
Starting development server at http://0.0.0.0:8080/
Quit the server with CONTROL-C.



spark.wsgi file looks like the following.

===

 import sys
import site
import os

vepath = '/var/www/html/virtualenv/lib/python2.7/site-packages'
prev_sys_path = list(sys.path)
site.addsitedir(vepath)
sys.path.append('/var/www/html/djangosites')
new_sys_path = [p for p in sys.path if p not in prev_sys_path]
for item in new_sys_path:
sys.path.remove(item)
sys.path[:0] = new_sys_path
from django.core.handlers.wsgi import WSGIHandler
os.environ['DJANGO_SETTINGS_MODULE'] = 'spark.settings'
application = WSGIHandler()

==

Entries for wsgi in apache conf looks like the following



[root@lampserver djangosites]# cat /etc/httpd/conf.d/django.conf


LoadModule wsgi_module modules/mod_wsgi.so
AddHandler wsgi-script .wsgi

WSGIScriptAlias / /var/www/html/djangosites/spark.wsgi

WSGIDaemonProcess spark processes=5 threads=15 display-name=%{GROUP}

WSGIProcessGroup spark

WSGIApplicationGroup %{GLOBAL}

WSGISocketPrefix /var/run/wsgi

=

Apache is running as user "apache".

My project files and permissions are shown below.

===
root@lampserver djangosites]# pwd
var/www/html/djangosites
[root@lampserver djangosites]# ls
spark  spark.wsgi
[root@lampserver djangosites]# ll
total 8
drwxr-xr-x 3 apache apache 4096 Nov 15 02:38 spark
-rwxrwxrwx 1 apache apache  535 Nov 15 03:16 spark.wsgi
[root@lampserver djangosites]# cd spark/
manage.py  spark/
[root@lampserver spark]# ll
total 8
-rwxr-xr-x 1 apache apache  248 Nov 15 02:38 manage.py
drwxr-xr-x 2 apache apache 4096 Nov 15 03:05 spark
[root@lampserver spark]# cd spark/
[root@lampserver spark]# ll
total 28
-rw-r--r-- 1 apache apache0 Nov 15 02:38 __init__.py
-rw-r--r-- 1 apache apache  136 Nov 15 02:40 __init__.pyc
-rw-r--r-- 1 apache apache 1969 Nov 15 02:38 settings.py
-rw-r--r-- 1 apache apache 2142 Nov 15 02:40 settings.pyc
-rw-r--r-- 1 apache apache  296 Nov 15 02:38 urls.py
-rw-

Streaming images with HttpResponse?

2013-11-15 Thread Alex Karargyris
I have this simple app that I opens webcam and processes the frames using 
OpenCV. In my views.py I have the following code:

def processImage():

while True:

rval, frame = settings.CAP.read()  //Read frames from webcam
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) //Make frame 
grayscale
pil_img = Image.fromarray(gray)  

response = HttpResponse(mimetype="image/png")
pil_img.save(response, "PNG")

return response

Although there is a while loop the function runs only once because it is 
broken by "return response". How could I change the code to make it run 
constantly?


-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a13fe785-83ec-4a18-8377-090bdeda279d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: mod_wsgi setup

2013-11-15 Thread tino
Thank you Fred for your help.

Finally I got it working. I tried different things and this is how my files 
looks  now.

spark.wsgi

=

import os
import sys
sys.stdout = sys.stderr
# Add the virtual Python environment site-packages directory to the path
import site
site.addsitedir('/var/www/html/virtualenv/lib/python2.7/site-packages')

#If your project is not on your PYTHONPATH by default you can add the 
following
sys.path.append('/var/www/html/djangosites/spark')
os.environ['DJANGO_SETTINGS_MODULE'] = 'spark.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

==

Apache entries

==

WSGIScriptAlias / /var/www/html/djangosites/spark.wsgi

WSGIDaemonProcess spark processes=5 threads=15 display-name=%{GROUP}

WSGIProcessGroup spark

WSGIApplicationGroup %{GLOBAL}

WSGISocketPrefix /var/run/wsgi



On Friday, November 15, 2013 3:04:58 PM UTC+5:30, tino wrote:
>
> Hello,
>
> I am trying to setup a python 2.7 + Django + virtualenv + mod_wsgi 
> environment in my centos 6.3 server to run my python application through 
> apache.
> But I am getting internal error while trying to access the application 
> through apache. The error log shows the following.
>
> 
> [Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] mod_wsgi 
> (pid=20361): Target WSGI script '/var/www/html/djangosites/spark.wsgi' 
> cannot be loaded as Python module.
> [Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] mod_wsgi 
> (pid=20361): Exception occurred processing WSGI script 
> '/var/www/html/djangosites/spark.wsgi'.
> Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] 
> ImproperlyConfigured: Requested setting DEBUG, but settings are not 
> configured. You must either define the environment variable 
> DJANGO_SETTINGS_MODULE or call settings.configure() before accessing 
> settings.
>
> 
>
> It is working fine when running as a test server.
>
> ==
> (virtualenv)[root@lampserver spark]# python manage.py runserver 
> 0.0.0.0:8080
> Validating models...
>
> 0 errors found
> November 15, 2013 - 09:15:19
> Django version 1.6, using settings 'spark.settings'
> Starting development server at http://0.0.0.0:8080/
> Quit the server with CONTROL-C.
> 
>
>
> spark.wsgi file looks like the following.
>
> ===
>
>  import sys
> import site
> import os
>
> vepath = '/var/www/html/virtualenv/lib/python2.7/site-packages'
> prev_sys_path = list(sys.path)
> site.addsitedir(vepath)
> sys.path.append('/var/www/html/djangosites')
> new_sys_path = [p for p in sys.path if p not in prev_sys_path]
> for item in new_sys_path:
> sys.path.remove(item)
> sys.path[:0] = new_sys_path
> from django.core.handlers.wsgi import WSGIHandler
> os.environ['DJANGO_SETTINGS_MODULE'] = 'spark.settings'
> application = WSGIHandler()
>
> ==
>
> Entries for wsgi in apache conf looks like the following
>
> 
>
> [root@lampserver djangosites]# cat /etc/httpd/conf.d/django.conf 
>
>
> LoadModule wsgi_module modules/mod_wsgi.so
> AddHandler wsgi-script .wsgi
>
> WSGIScriptAlias / /var/www/html/djangosites/spark.wsgi
>
> WSGIDaemonProcess spark processes=5 threads=15 display-name=%{GROUP}
>
> WSGIProcessGroup spark
>
> WSGIApplicationGroup %{GLOBAL}
>
> WSGISocketPrefix /var/run/wsgi
>
> =
>
> Apache is running as user "apache".
>
> My project files and permissions are shown below.
>
> ===
> root@lampserver djangosites]# pwd
> var/www/html/djangosites
> [root@lampserver djangosites]# ls
> spark  spark.wsgi
> [root@lampserver djangosites]# ll
> total 8
> drwxr-xr-x 3 apache apache 4096 Nov 15 02:38 spark
> -rwxrwxrwx 1 apache apache  535 Nov 15 03:16 spark.wsgi
> [root@lampserver djangosites]# cd spark/
> manage.py  spark/ 
> [root@lampserver spark]# ll
> total 8
> -rwxr-xr-x 1 apache apache  248 Nov 15 02:38 manage.py
> drwxr-xr-x 2 apache apache 4096 Nov 15 03:05 spark
> [root@lampserver spark]# cd spark/
> [root@lampserver spark]# ll
> total 28
> -rw-r--r-- 1 apache apache0 Nov 15 02:38 __init__.py
> -rw-r--r-- 1 apache apache  136 Nov 15 02:40 __init__.pyc
> -rw-r--r-- 1 apache apache 1969 Nov 15 02:38 settings.py
> -rw-r--r-- 1 apache apache 2142 Nov 15 02:40 settings.pyc
> -rw-r--r-- 1 apache apache  296 Nov 15 02:38 urls.py
> -rw-r--r-- 1 apache apache  416 Nov 15 02:40 urls.pyc
> -rwxr-xr-x 1 apache apache  385 Nov 15 02:38 wsgi.py
> -rw-r--r-- 1 apache apache  589 Nov 15 02:40 wsgi.pyc
>
> ==
>
> Can anybody please identify the problem with my settings?
>
> 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 http://groups.google.com/group/django-users.
To

Re: mod_wsgi setup

2013-11-15 Thread Fred Stluka

tino,

I have a working setup, using Apache mod_wsgi on AWS Linux.

Try adding the location of your virtual env to to your Apache settings.
Something like:

==

WSGIPythonHome /var/python27/virtualenvs/hhl

==

If that doesn't help, here are some more thoughts.

My django.wsgi file looks similar to yours.  Differences in red:

==

import os, sys
sys.path.append('/var/www/django/hhlweb')
sys.path.append('/var/www/django/hhlweb/hhl')
sys.path.append('/var/python27/virtualenvs/hhl/lib/python2.7/site-packages/django/db/backends')
os.environ['DJANGO_SETTINGS_MODULE'] = 'hhl.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

==

What does your wsgi.py file look like?  Mine is:

==

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hhl.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

==

I found these links useful when I set mine up last year:
- http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
- http://code.google.com/p/modwsgi/wiki/ConfigurationIssues
- https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi


--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.


On 11/15/13 8:28 AM, tino wrote:

Thank you guys for the suggestions.

But selinux is already disabled in the server.

 [root@lampserver spark]# getenforce
Disabled

Also I tried to set
 DEBUG = False  in settings.py. That also did not help.


On Friday, November 15, 2013 3:04:58 PM UTC+5:30, tino wrote:

Hello,

I am trying to setup a python 2.7 + Django + virtualenv + mod_wsgi
environment in my centos 6.3 server to run my python application
through apache.
But I am getting internal error while trying to access the
application through apache. The error log shows the following.


[Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54]
mod_wsgi (pid=20361): Target WSGI script
'/var/www/html/djangosites/spark.wsgi' cannot be loaded as Python
module.
[Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54]
mod_wsgi (pid=20361): Exception occurred processing WSGI script
'/var/www/html/djangosites/spark.wsgi'.
Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54]
ImproperlyConfigured: Requested setting DEBUG, but settings are
not configured. You must either define the environment variable
DJANGO_SETTINGS_MODULE or call settings.configure() before
accessing settings.



It is working fine when running as a test server.

==
(virtualenv)[root@lampserver spark]# python manage.py runserver
0.0.0.0:8080 
Validating models...

0 errors found
November 15, 2013 - 09:15:19
Django version 1.6, using settings 'spark.settings'
Starting development server at http://0.0.0.0:8080/
Quit the server with CONTROL-C.



spark.wsgi file looks like the following.

===

 import sys
import site
import os

vepath = '/var/www/html/virtualenv/lib/python2.7/site-packages'
prev_sys_path = list(sys.path)
site.addsitedir(vepath)
sys.path.append('/var/www/html/djangosites')
new_sys_path = [p for p in sys.path if p not in prev_sys_path]
for item in new_sys_path:
sys.path.remove(item)
sys.path[:0] = new_sys_path
from django.core.handlers.wsgi import WSGIHandler
os.environ['DJANGO_SETTINGS_MODULE'] = 'spark.settings'
application = WSGIHandler()

==

Entries for wsgi in apache conf looks like the following



[root@lampserver djangosites]# cat /etc/httpd/conf.d/django.conf


LoadModule wsgi_module modules/mod_wsgi.so
AddHandler wsgi-script .wsgi

WSGIScriptAlias / /var/www/html/djangosites/spark.wsgi

WSGIDaemonProcess spark processes=5 threads=15 display-name=%{GROUP}

WSGIProcessGroup spark

WSGIApplicationGroup %{GLOBAL}

WSGISocketPrefix /var/run/wsgi

=

Apache is running as user "apache".

My project files and permissions are shown below.

===
root@lampserver djangosites]# pwd
var/www/html/djangosites
[root@lampserver djangosites]# ls
spark  spark.wsgi
[root@lampserver djangosites]# ll
total 8
drwxr-xr-x 3 apache apache 4096 Nov 15 02:38 spark
-rwxrwxrwx 1 apache apache  535 Nov 15 03:16 spark.wsgi
[root@lampserver djangosites]# cd spark/
manage.py  spark/
[root@lampserver spark]# ll
total 8
-rwxr-xr-x 1 apache apache  248 Nov 

Re: Why is RequestContext used in this way?

2013-11-15 Thread Tom Evans
On Fri, Nov 15, 2013 at 12:59 PM, Andrew Taylor  wrote:
>
>
> Hi,
>
> I've followed some example code which is is follows:
>
> def index(request):
> context = RequestContext(request)
> context_dict =  {'boldmessage': "I am from the context"}
> return render_to_response('rango/index.html',context_dict, context)
>
> Here RequestContext only has the first argument filled i.e. request.
>
> My questions are:
>
> 1. Is RequestContext(request) being used in a kind of dummy way to suck up 
> the context processors for render_to_response?
> 2. What would render_to_response be doing if has both context_dict AND 
> RequestContext had a second argument?
>
> Sorry if these are stupid questions. I'm new to everything python and Dango, 
> and the kind of person who forgets everything they have ever known when 
> trying to decide which pack of toilet paper to buy in the supermarket.
>

This is explained in the docs:

If you do not pass in a context, a Context will be created from the
dictionary passed in.
If you do pass in a context, the contents of the dictionary passed in
will be merged in to the context.

https://docs.djangoproject.com/en/1.6/topics/http/shortcuts/#django.shortcuts.render_to_response

Cheers

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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1K_gQej9-_PXWd7Nsr8UvfZ7OZ-UmpHq9oDH7LfmhuT0Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Why is RequestContext used in this way?

2013-11-15 Thread Fred Stluka

Andy,

RequestContext is being passed in so that it become available
to the template, so that it can do things like {% csrf_token %}
which requires access to the session id.

I'm not sure what would happen if a dictionary were passed to
RequestContext as an optional 2nd argument.  I've always
passed the dictionary directly to render_to_response().

--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.


On 11/15/13 7:59 AM, Andrew Taylor wrote:


Hi,

I've followed some example code which is is follows:

def index(request):
context = RequestContext(request)
context_dict =  {'boldmessage': "I am from the context"}
return render_to_response('rango/index.html',context_dict, context)

Here RequestContext only has the first argument filled i.e. request.

My questions are:

1. Is RequestContext(request) being used in a kind of dummy way to 
suck up the context processors for render_to_response?
2. What would render_to_response be doing if has both context_dict AND 
RequestContext had a second argument?


Sorry if these are stupid questions. I'm new to everything python and 
Dango, and the kind of person who forgets everything they have ever 
known when trying to decide which pack of toilet paper to buy in the 
supermarket.


Andy

--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9f62f09d-cf92-46e2-893c-17d0a39fe4a5%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.


--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/528628C9.5070003%40bristle.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: mod_wsgi setup

2013-11-15 Thread tino
Thank you guys for the suggestions.

But selinux is already disabled in the server.

 [root@lampserver spark]# getenforce 
Disabled

Also I tried to set 
 DEBUG = False  in settings.py. That also did not help.


On Friday, November 15, 2013 3:04:58 PM UTC+5:30, tino wrote:
>
> Hello,
>
> I am trying to setup a python 2.7 + Django + virtualenv + mod_wsgi 
> environment in my centos 6.3 server to run my python application through 
> apache.
> But I am getting internal error while trying to access the application 
> through apache. The error log shows the following.
>
> 
> [Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] mod_wsgi 
> (pid=20361): Target WSGI script '/var/www/html/djangosites/spark.wsgi' 
> cannot be loaded as Python module.
> [Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] mod_wsgi 
> (pid=20361): Exception occurred processing WSGI script 
> '/var/www/html/djangosites/spark.wsgi'.
> Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] 
> ImproperlyConfigured: Requested setting DEBUG, but settings are not 
> configured. You must either define the environment variable 
> DJANGO_SETTINGS_MODULE or call settings.configure() before accessing 
> settings.
>
> 
>
> It is working fine when running as a test server.
>
> ==
> (virtualenv)[root@lampserver spark]# python manage.py runserver 
> 0.0.0.0:8080
> Validating models...
>
> 0 errors found
> November 15, 2013 - 09:15:19
> Django version 1.6, using settings 'spark.settings'
> Starting development server at http://0.0.0.0:8080/
> Quit the server with CONTROL-C.
> 
>
>
> spark.wsgi file looks like the following.
>
> ===
>
>  import sys
> import site
> import os
>
> vepath = '/var/www/html/virtualenv/lib/python2.7/site-packages'
> prev_sys_path = list(sys.path)
> site.addsitedir(vepath)
> sys.path.append('/var/www/html/djangosites')
> new_sys_path = [p for p in sys.path if p not in prev_sys_path]
> for item in new_sys_path:
> sys.path.remove(item)
> sys.path[:0] = new_sys_path
> from django.core.handlers.wsgi import WSGIHandler
> os.environ['DJANGO_SETTINGS_MODULE'] = 'spark.settings'
> application = WSGIHandler()
>
> ==
>
> Entries for wsgi in apache conf looks like the following
>
> 
>
> [root@lampserver djangosites]# cat /etc/httpd/conf.d/django.conf 
>
>
> LoadModule wsgi_module modules/mod_wsgi.so
> AddHandler wsgi-script .wsgi
>
> WSGIScriptAlias / /var/www/html/djangosites/spark.wsgi
>
> WSGIDaemonProcess spark processes=5 threads=15 display-name=%{GROUP}
>
> WSGIProcessGroup spark
>
> WSGIApplicationGroup %{GLOBAL}
>
> WSGISocketPrefix /var/run/wsgi
>
> =
>
> Apache is running as user "apache".
>
> My project files and permissions are shown below.
>
> ===
> root@lampserver djangosites]# pwd
> var/www/html/djangosites
> [root@lampserver djangosites]# ls
> spark  spark.wsgi
> [root@lampserver djangosites]# ll
> total 8
> drwxr-xr-x 3 apache apache 4096 Nov 15 02:38 spark
> -rwxrwxrwx 1 apache apache  535 Nov 15 03:16 spark.wsgi
> [root@lampserver djangosites]# cd spark/
> manage.py  spark/ 
> [root@lampserver spark]# ll
> total 8
> -rwxr-xr-x 1 apache apache  248 Nov 15 02:38 manage.py
> drwxr-xr-x 2 apache apache 4096 Nov 15 03:05 spark
> [root@lampserver spark]# cd spark/
> [root@lampserver spark]# ll
> total 28
> -rw-r--r-- 1 apache apache0 Nov 15 02:38 __init__.py
> -rw-r--r-- 1 apache apache  136 Nov 15 02:40 __init__.pyc
> -rw-r--r-- 1 apache apache 1969 Nov 15 02:38 settings.py
> -rw-r--r-- 1 apache apache 2142 Nov 15 02:40 settings.pyc
> -rw-r--r-- 1 apache apache  296 Nov 15 02:38 urls.py
> -rw-r--r-- 1 apache apache  416 Nov 15 02:40 urls.pyc
> -rwxr-xr-x 1 apache apache  385 Nov 15 02:38 wsgi.py
> -rw-r--r-- 1 apache apache  589 Nov 15 02:40 wsgi.pyc
>
> ==
>
> Can anybody please identify the problem with my settings?
>
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6a96d3b1-bf4c-4045-920a-cac5b7d80893%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Why is RequestContext used in this way?

2013-11-15 Thread Andrew Taylor

Hi,

I've followed some example code which is is follows:

def index(request):
context = RequestContext(request)
context_dict =  {'boldmessage': "I am from the context"}
return render_to_response('rango/index.html',context_dict, context)

Here RequestContext only has the first argument filled i.e. request.

My questions are:

1. Is RequestContext(request) being used in a kind of dummy way to suck up 
the context processors for render_to_response?
2. What would render_to_response be doing if has both context_dict AND 
RequestContext had a second argument?

Sorry if these are stupid questions. I'm new to everything python and 
Dango, and the kind of person who forgets everything they have ever known 
when trying to decide which pack of toilet paper to buy in the supermarket.

Andy

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9f62f09d-cf92-46e2-893c-17d0a39fe4a5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Is this what you would expect from this Q query?

2013-11-15 Thread Phoebe Bright
Aghh, the light has gone one.  The issue is in my models:


from django.db import models

from django.contrib.auth.models import User

class Carbon(models.Model):
user = models.ForeignKey(User, blank=True, null=True) <- 
 allowing null causes extra clause to be added in queryset
kg = models.DecimalField(max_digits=18, decimal_places=6, default=1)



To reproduce:

from web.models import *
from django.contrib.auth.models import User

u1=User.objects.create_user('A', 'a...@test.com', 'test')
u2=User.objects.create_user('B', 'b...@test.com', 'test')
u3=User.objects.create_user('C', 'c...@test.com', 'test')
u4=User.objects.create_user('D', 'd...@test.com', 'test')

Carbon.objects.create(user=u1, kg=10)
Carbon.objects.create(user=u2, kg=10)
Carbon.objects.create(user=u3, kg=10)
Carbon.objects.create(user=u4, kg=10)

rest = Carbon.objects.filter(~Q(user__in = 
[u1,u2,u3])).aggregate(total=Sum('kg'))

rest2 = Carbon.objects.exclude(user__in = 
[u1,u2,u3]).aggregate(total=Sum('kg'))


from django.db import connection
connection.queries

So simple in the end.

Thank you both for helping resolve this.  Will tighten up my model and 
remove option for a blank user.

Phoebe.


On Thursday, 14 November 2013 16:15:31 UTC, akaariai wrote:
>
> On Thursday, November 14, 2013 2:17:43 PM UTC+2, Phoebe Bright wrote:
>>
>> After a long time trying to create a simple version that would replicate 
>> the error, and failing, I've tracked it through the original code.
>>
>> Line 1140 in django/db/models/sql/query.py in function build_filter
>>
>> if current_negated and (lookup_type != 'isnull' or value is 
>> False):
>> self.promote_joins(join_list)
>> if (lookup_type != 'isnull' and (
>> self.is_nullable(targets[0]) or
>> self.alias_map[join_list[-1]].join_type == 
>> self.LOUTER)):
>> # The condition added here will be SQL like this:
>> # NOT (col IS NOT NULL), where the first NOT is added in
>> # upper layers of code. The reason for addition is that 
>> if col
>> # is null, then col != someval will result in SQL 
>> "unknown"
>> # which isn't the same as in Python. The Python None 
>> handling
>> # is wanted, and it can be gotten by
>> # (col IS NULL OR col != someval)
>> #   <=>
>> # NOT (col IS NOT NULL AND col = someval).
>> clause.add((Constraint(alias, targets[0].column, None), 
>> 'isnull', False), AND)  < this is adding the spurious clause
>>
>> This is django version 1.6 and happens using both the original Q version 
>> and using your suggested .exclude version.  
>> Having found it I'm still not sure what it means or how to avoid it being 
>> triggered!
>>
>> Any suggestions?
>>
>
> I believe the query is actually correct. The idea is that 
> .exclude(condition) produces complement of .filter(condition). The simplest 
> example I can generate is using raw SQL on PostgreSQL:
> akaariai=# create temp table foo(id integer);
> CREATE TABLE
> akaariai=# insert into foo values(null);
> INSERT 0 1
> -- What .filter(id__in=[1, 2, 3]) will do:
> akaariai=# select * from foo where id in (1, 2, 3);
>  id 
> 
> (0 rows)
>
> -- If the  "id is not null" condition isn't there
> akaariai=# select * from foo where not (id in (1, 2, 3));
>  id 
> 
> (0 rows)
>
> -- Note: we get still zero rows while we should get the complement, that 
> is one row.
> -- Add in the id is not null condition
> akaariai=# select * from foo where not (id in (1, 2, 3) and id is not 
> null);
>  id 
> 
>
> (1 row)
> -- Now we got the complement of the .filter() query.
>
> The problem comes from this feature in SQL:
>   NULL in (1, 2, 3) => unknown
>   NOT (NULL in (1, 2, 3)) => unknown
> so, NOT (condition) doesn't produce complement of (condition) in SQL! To 
> avoid that problem we have to add the AND id IS NOT NULL into the condition.
>
>  - Anssi
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1cd0e599-67ff-4067-a23d-ed2d06017dac%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: mod_wsgi setup

2013-11-15 Thread Timothy W. Cook
BTW:  HEre is an old tutorial regarding SELinux and WSGI apps.  It may
be useful?
http://www.packtpub.com/article/selinux-secured-web-hosting-python-based-web-applications


On Fri, Nov 15, 2013 at 8:17 AM, Timothy W. Cook  wrote:
> On centos 6 I had (still have) problems similar to this due to SELinux
> restricting Apache from accessing the application.  Even after
> rechecking permissions SELinux doesn't want to allow a user to access
> another users (specifically setup for the application)  home
> directory.  You can test if this is the same problem by disabling
> SELinux temporarily with:
>
> $setenforce 0
>
> This is really a temporary fix and exploring
> http://www.crypt.gen.nz/selinux/disable_selinux.html may help.
>
> HTH,
> Tim
>
>
> On Fri, Nov 15, 2013 at 8:09 AM, Liam Thompson  wrote:
>> The "Requested setting DEBUG" says you've requested DEBUG but it's not
>> setup. I don't think you would want DEBUG in production, so try to turn that
>> off in the settings file.
>>
>>
>> On Friday, 15 November 2013 11:34:58 UTC+2, tino wrote:
>>>
>>> Hello,
>>>
>>> I am trying to setup a python 2.7 + Django + virtualenv + mod_wsgi
>>> environment in my centos 6.3 server to run my python application through
>>> apache.
>>> But I am getting internal error while trying to access the application
>>> through apache. The error log shows the following.
>>>
>>> 
>>> [Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] mod_wsgi
>>> (pid=20361): Target WSGI script '/var/www/html/djangosites/spark.wsgi'
>>> cannot be loaded as Python module.
>>> [Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] mod_wsgi
>>> (pid=20361): Exception occurred processing WSGI script
>>> '/var/www/html/djangosites/spark.wsgi'.
>>> Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54]
>>> ImproperlyConfigured: Requested setting DEBUG, but settings are not
>>> configured. You must either define the environment variable
>>> DJANGO_SETTINGS_MODULE or call settings.configure() before accessing
>>> settings.
>>>
>>> 
>>>
>>> It is working fine when running as a test server.
>>>
>>> ==
>>> (virtualenv)[root@lampserver spark]# python manage.py runserver
>>> 0.0.0.0:8080
>>> Validating models...
>>>
>>> 0 errors found
>>> November 15, 2013 - 09:15:19
>>> Django version 1.6, using settings 'spark.settings'
>>> Starting development server at http://0.0.0.0:8080/
>>> Quit the server with CONTROL-C.
>>> 
>>>
>>>
>>> spark.wsgi file looks like the following.
>>>
>>> ===
>>>
>>>  import sys
>>> import site
>>> import os
>>>
>>> vepath = '/var/www/html/virtualenv/lib/python2.7/site-packages'
>>> prev_sys_path = list(sys.path)
>>> site.addsitedir(vepath)
>>> sys.path.append('/var/www/html/djangosites')
>>> new_sys_path = [p for p in sys.path if p not in prev_sys_path]
>>> for item in new_sys_path:
>>> sys.path.remove(item)
>>> sys.path[:0] = new_sys_path
>>> from django.core.handlers.wsgi import WSGIHandler
>>> os.environ['DJANGO_SETTINGS_MODULE'] = 'spark.settings'
>>> application = WSGIHandler()
>>>
>>> ==
>>>
>>> Entries for wsgi in apache conf looks like the following
>>>
>>> 
>>>
>>> [root@lampserver djangosites]# cat /etc/httpd/conf.d/django.conf
>>>
>>>
>>> LoadModule wsgi_module modules/mod_wsgi.so
>>> AddHandler wsgi-script .wsgi
>>>
>>> WSGIScriptAlias / /var/www/html/djangosites/spark.wsgi
>>>
>>> WSGIDaemonProcess spark processes=5 threads=15 display-name=%{GROUP}
>>>
>>> WSGIProcessGroup spark
>>>
>>> WSGIApplicationGroup %{GLOBAL}
>>>
>>> WSGISocketPrefix /var/run/wsgi
>>>
>>> =
>>>
>>> Apache is running as user "apache".
>>>
>>> My project files and permissions are shown below.
>>>
>>> ===
>>> root@lampserver djangosites]# pwd
>>> var/www/html/djangosites
>>> [root@lampserver djangosites]# ls
>>> spark  spark.wsgi
>>> [root@lampserver djangosites]# ll
>>> total 8
>>> drwxr-xr-x 3 apache apache 4096 Nov 15 02:38 spark
>>> -rwxrwxrwx 1 apache apache  535 Nov 15 03:16 spark.wsgi
>>> [root@lampserver djangosites]# cd spark/
>>> manage.py  spark/
>>> [root@lampserver spark]# ll
>>> total 8
>>> -rwxr-xr-x 1 apache apache  248 Nov 15 02:38 manage.py
>>> drwxr-xr-x 2 apache apache 4096 Nov 15 03:05 spark
>>> [root@lampserver spark]# cd spark/
>>> [root@lampserver spark]# ll
>>> total 28
>>> -rw-r--r-- 1 apache apache0 Nov 15 02:38 __init__.py
>>> -rw-r--r-- 1 apache apache  136 Nov 15 02:40 __init__.pyc
>>> -rw-r--r-- 1 apache apache 1969 Nov 15 02:38 settings.py
>>> -rw-r--r-- 1 apache apache 2142 Nov 15 02:40 settings.pyc
>>> -rw-r--r-- 1 apache apache  296 Nov 15 02:38 urls.py
>>> -rw-r--r-- 1 apache apache  416 Nov 15 02:40 urls.pyc
>>> -rwxr-xr-x 1 apache apache  385 Nov 15 02:38 wsgi.py
>>> -rw-r--r-- 1 apache apache  589 Nov 15 02:40 wsgi.pyc
>>>
>>> ==
>>>
>>> Can anybody please identify the problem with my settings?
>>>
>>> Regards
>>
>> --
>> You received this message because you are subscribed to the Google Group

Re: mod_wsgi setup

2013-11-15 Thread Timothy W. Cook
On centos 6 I had (still have) problems similar to this due to SELinux
restricting Apache from accessing the application.  Even after
rechecking permissions SELinux doesn't want to allow a user to access
another users (specifically setup for the application)  home
directory.  You can test if this is the same problem by disabling
SELinux temporarily with:

$setenforce 0

This is really a temporary fix and exploring
http://www.crypt.gen.nz/selinux/disable_selinux.html may help.

HTH,
Tim


On Fri, Nov 15, 2013 at 8:09 AM, Liam Thompson  wrote:
> The "Requested setting DEBUG" says you've requested DEBUG but it's not
> setup. I don't think you would want DEBUG in production, so try to turn that
> off in the settings file.
>
>
> On Friday, 15 November 2013 11:34:58 UTC+2, tino wrote:
>>
>> Hello,
>>
>> I am trying to setup a python 2.7 + Django + virtualenv + mod_wsgi
>> environment in my centos 6.3 server to run my python application through
>> apache.
>> But I am getting internal error while trying to access the application
>> through apache. The error log shows the following.
>>
>> 
>> [Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] mod_wsgi
>> (pid=20361): Target WSGI script '/var/www/html/djangosites/spark.wsgi'
>> cannot be loaded as Python module.
>> [Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] mod_wsgi
>> (pid=20361): Exception occurred processing WSGI script
>> '/var/www/html/djangosites/spark.wsgi'.
>> Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54]
>> ImproperlyConfigured: Requested setting DEBUG, but settings are not
>> configured. You must either define the environment variable
>> DJANGO_SETTINGS_MODULE or call settings.configure() before accessing
>> settings.
>>
>> 
>>
>> It is working fine when running as a test server.
>>
>> ==
>> (virtualenv)[root@lampserver spark]# python manage.py runserver
>> 0.0.0.0:8080
>> Validating models...
>>
>> 0 errors found
>> November 15, 2013 - 09:15:19
>> Django version 1.6, using settings 'spark.settings'
>> Starting development server at http://0.0.0.0:8080/
>> Quit the server with CONTROL-C.
>> 
>>
>>
>> spark.wsgi file looks like the following.
>>
>> ===
>>
>>  import sys
>> import site
>> import os
>>
>> vepath = '/var/www/html/virtualenv/lib/python2.7/site-packages'
>> prev_sys_path = list(sys.path)
>> site.addsitedir(vepath)
>> sys.path.append('/var/www/html/djangosites')
>> new_sys_path = [p for p in sys.path if p not in prev_sys_path]
>> for item in new_sys_path:
>> sys.path.remove(item)
>> sys.path[:0] = new_sys_path
>> from django.core.handlers.wsgi import WSGIHandler
>> os.environ['DJANGO_SETTINGS_MODULE'] = 'spark.settings'
>> application = WSGIHandler()
>>
>> ==
>>
>> Entries for wsgi in apache conf looks like the following
>>
>> 
>>
>> [root@lampserver djangosites]# cat /etc/httpd/conf.d/django.conf
>>
>>
>> LoadModule wsgi_module modules/mod_wsgi.so
>> AddHandler wsgi-script .wsgi
>>
>> WSGIScriptAlias / /var/www/html/djangosites/spark.wsgi
>>
>> WSGIDaemonProcess spark processes=5 threads=15 display-name=%{GROUP}
>>
>> WSGIProcessGroup spark
>>
>> WSGIApplicationGroup %{GLOBAL}
>>
>> WSGISocketPrefix /var/run/wsgi
>>
>> =
>>
>> Apache is running as user "apache".
>>
>> My project files and permissions are shown below.
>>
>> ===
>> root@lampserver djangosites]# pwd
>> var/www/html/djangosites
>> [root@lampserver djangosites]# ls
>> spark  spark.wsgi
>> [root@lampserver djangosites]# ll
>> total 8
>> drwxr-xr-x 3 apache apache 4096 Nov 15 02:38 spark
>> -rwxrwxrwx 1 apache apache  535 Nov 15 03:16 spark.wsgi
>> [root@lampserver djangosites]# cd spark/
>> manage.py  spark/
>> [root@lampserver spark]# ll
>> total 8
>> -rwxr-xr-x 1 apache apache  248 Nov 15 02:38 manage.py
>> drwxr-xr-x 2 apache apache 4096 Nov 15 03:05 spark
>> [root@lampserver spark]# cd spark/
>> [root@lampserver spark]# ll
>> total 28
>> -rw-r--r-- 1 apache apache0 Nov 15 02:38 __init__.py
>> -rw-r--r-- 1 apache apache  136 Nov 15 02:40 __init__.pyc
>> -rw-r--r-- 1 apache apache 1969 Nov 15 02:38 settings.py
>> -rw-r--r-- 1 apache apache 2142 Nov 15 02:40 settings.pyc
>> -rw-r--r-- 1 apache apache  296 Nov 15 02:38 urls.py
>> -rw-r--r-- 1 apache apache  416 Nov 15 02:40 urls.pyc
>> -rwxr-xr-x 1 apache apache  385 Nov 15 02:38 wsgi.py
>> -rw-r--r-- 1 apache apache  589 Nov 15 02:40 wsgi.pyc
>>
>> ==
>>
>> Can anybody please identify the problem with my settings?
>>
>> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/359

Re: mod_wsgi setup

2013-11-15 Thread Liam Thompson
The "Requested setting DEBUG" says you've requested DEBUG but it's not 
setup. I don't think you would want DEBUG in production, so try to turn 
that off in the settings file.


On Friday, 15 November 2013 11:34:58 UTC+2, tino wrote:
>
> Hello,
>
> I am trying to setup a python 2.7 + Django + virtualenv + mod_wsgi 
> environment in my centos 6.3 server to run my python application through 
> apache.
> But I am getting internal error while trying to access the application 
> through apache. The error log shows the following.
>
> 
> [Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] mod_wsgi 
> (pid=20361): Target WSGI script '/var/www/html/djangosites/spark.wsgi' 
> cannot be loaded as Python module.
> [Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] mod_wsgi 
> (pid=20361): Exception occurred processing WSGI script 
> '/var/www/html/djangosites/spark.wsgi'.
> Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] 
> ImproperlyConfigured: Requested setting DEBUG, but settings are not 
> configured. You must either define the environment variable 
> DJANGO_SETTINGS_MODULE or call settings.configure() before accessing 
> settings.
>
> 
>
> It is working fine when running as a test server.
>
> ==
> (virtualenv)[root@lampserver spark]# python manage.py runserver 
> 0.0.0.0:8080
> Validating models...
>
> 0 errors found
> November 15, 2013 - 09:15:19
> Django version 1.6, using settings 'spark.settings'
> Starting development server at http://0.0.0.0:8080/
> Quit the server with CONTROL-C.
> 
>
>
> spark.wsgi file looks like the following.
>
> ===
>
>  import sys
> import site
> import os
>
> vepath = '/var/www/html/virtualenv/lib/python2.7/site-packages'
> prev_sys_path = list(sys.path)
> site.addsitedir(vepath)
> sys.path.append('/var/www/html/djangosites')
> new_sys_path = [p for p in sys.path if p not in prev_sys_path]
> for item in new_sys_path:
> sys.path.remove(item)
> sys.path[:0] = new_sys_path
> from django.core.handlers.wsgi import WSGIHandler
> os.environ['DJANGO_SETTINGS_MODULE'] = 'spark.settings'
> application = WSGIHandler()
>
> ==
>
> Entries for wsgi in apache conf looks like the following
>
> 
>
> [root@lampserver djangosites]# cat /etc/httpd/conf.d/django.conf 
>
>
> LoadModule wsgi_module modules/mod_wsgi.so
> AddHandler wsgi-script .wsgi
>
> WSGIScriptAlias / /var/www/html/djangosites/spark.wsgi
>
> WSGIDaemonProcess spark processes=5 threads=15 display-name=%{GROUP}
>
> WSGIProcessGroup spark
>
> WSGIApplicationGroup %{GLOBAL}
>
> WSGISocketPrefix /var/run/wsgi
>
> =
>
> Apache is running as user "apache".
>
> My project files and permissions are shown below.
>
> ===
> root@lampserver djangosites]# pwd
> var/www/html/djangosites
> [root@lampserver djangosites]# ls
> spark  spark.wsgi
> [root@lampserver djangosites]# ll
> total 8
> drwxr-xr-x 3 apache apache 4096 Nov 15 02:38 spark
> -rwxrwxrwx 1 apache apache  535 Nov 15 03:16 spark.wsgi
> [root@lampserver djangosites]# cd spark/
> manage.py  spark/ 
> [root@lampserver spark]# ll
> total 8
> -rwxr-xr-x 1 apache apache  248 Nov 15 02:38 manage.py
> drwxr-xr-x 2 apache apache 4096 Nov 15 03:05 spark
> [root@lampserver spark]# cd spark/
> [root@lampserver spark]# ll
> total 28
> -rw-r--r-- 1 apache apache0 Nov 15 02:38 __init__.py
> -rw-r--r-- 1 apache apache  136 Nov 15 02:40 __init__.pyc
> -rw-r--r-- 1 apache apache 1969 Nov 15 02:38 settings.py
> -rw-r--r-- 1 apache apache 2142 Nov 15 02:40 settings.pyc
> -rw-r--r-- 1 apache apache  296 Nov 15 02:38 urls.py
> -rw-r--r-- 1 apache apache  416 Nov 15 02:40 urls.pyc
> -rwxr-xr-x 1 apache apache  385 Nov 15 02:38 wsgi.py
> -rw-r--r-- 1 apache apache  589 Nov 15 02:40 wsgi.pyc
>
> ==
>
> Can anybody please identify the problem with my settings?
>
> 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3594a141-c38c-4efa-850a-be2f75dafaf7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


mod_wsgi setup

2013-11-15 Thread tino
Hello,

I am trying to setup a python 2.7 + Django + virtualenv + mod_wsgi 
environment in my centos 6.3 server to run my python application through 
apache.
But I am getting internal error while trying to access the application 
through apache. The error log shows the following.


[Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] mod_wsgi 
(pid=20361): Target WSGI script '/var/www/html/djangosites/spark.wsgi' 
cannot be loaded as Python module.
[Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] mod_wsgi 
(pid=20361): Exception occurred processing WSGI script 
'/var/www/html/djangosites/spark.wsgi'.
Fri Nov 15 04:20:30 2013] [error] [client 117.201.194.54] 
ImproperlyConfigured: Requested setting DEBUG, but settings are not 
configured. You must either define the environment variable 
DJANGO_SETTINGS_MODULE or call settings.configure() before accessing 
settings.



It is working fine when running as a test server.

==
(virtualenv)[root@lampserver spark]# python manage.py runserver 0.0.0.0:8080
Validating models...

0 errors found
November 15, 2013 - 09:15:19
Django version 1.6, using settings 'spark.settings'
Starting development server at http://0.0.0.0:8080/
Quit the server with CONTROL-C.



spark.wsgi file looks like the following.

===

 import sys
import site
import os

vepath = '/var/www/html/virtualenv/lib/python2.7/site-packages'
prev_sys_path = list(sys.path)
site.addsitedir(vepath)
sys.path.append('/var/www/html/djangosites')
new_sys_path = [p for p in sys.path if p not in prev_sys_path]
for item in new_sys_path:
sys.path.remove(item)
sys.path[:0] = new_sys_path
from django.core.handlers.wsgi import WSGIHandler
os.environ['DJANGO_SETTINGS_MODULE'] = 'spark.settings'
application = WSGIHandler()

==

Entries for wsgi in apache conf looks like the following



[root@lampserver djangosites]# cat /etc/httpd/conf.d/django.conf 


LoadModule wsgi_module modules/mod_wsgi.so
AddHandler wsgi-script .wsgi

WSGIScriptAlias / /var/www/html/djangosites/spark.wsgi

WSGIDaemonProcess spark processes=5 threads=15 display-name=%{GROUP}

WSGIProcessGroup spark

WSGIApplicationGroup %{GLOBAL}

WSGISocketPrefix /var/run/wsgi

=

Apache is running as user "apache".

My project files and permissions are shown below.

===
root@lampserver djangosites]# pwd
var/www/html/djangosites
[root@lampserver djangosites]# ls
spark  spark.wsgi
[root@lampserver djangosites]# ll
total 8
drwxr-xr-x 3 apache apache 4096 Nov 15 02:38 spark
-rwxrwxrwx 1 apache apache  535 Nov 15 03:16 spark.wsgi
[root@lampserver djangosites]# cd spark/
manage.py  spark/ 
[root@lampserver spark]# ll
total 8
-rwxr-xr-x 1 apache apache  248 Nov 15 02:38 manage.py
drwxr-xr-x 2 apache apache 4096 Nov 15 03:05 spark
[root@lampserver spark]# cd spark/
[root@lampserver spark]# ll
total 28
-rw-r--r-- 1 apache apache0 Nov 15 02:38 __init__.py
-rw-r--r-- 1 apache apache  136 Nov 15 02:40 __init__.pyc
-rw-r--r-- 1 apache apache 1969 Nov 15 02:38 settings.py
-rw-r--r-- 1 apache apache 2142 Nov 15 02:40 settings.pyc
-rw-r--r-- 1 apache apache  296 Nov 15 02:38 urls.py
-rw-r--r-- 1 apache apache  416 Nov 15 02:40 urls.pyc
-rwxr-xr-x 1 apache apache  385 Nov 15 02:38 wsgi.py
-rw-r--r-- 1 apache apache  589 Nov 15 02:40 wsgi.pyc

==

Can anybody please identify the problem with my settings?

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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6e9372db-861f-4130-90fa-06c06d7c67d0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django 1.6 error at creating project

2013-11-15 Thread Timothy W. Cook
Well, of course now you have a great OS in the VM. :-)

However, even using Linux, please note that he was referring to a
virtual Python environment.  You should take a look at the link he
provided.  It will save you a lot of headaches.

On Thu, Nov 14, 2013 at 11:41 PM, Vibhu Rishi  wrote:
> I work exactly as you have mentioned .. In a xubuntu VM :)
>
> V.
>
> On Nov 13, 2013 11:17 AM, "Ferdy Rodríguez" 
> wrote:
>>
>> Hi,
>>
>> Yes, I always work with virtual environments, and I've checked that I did
>> download django 1.6. However, I looks like is a problem with my Windows
>> OS I fired up a Virtual Machine with Ubuntu and everything is working
>> fine.
>>
>> So I'm testing my code in the Virtual box.
>>
>> Thanks for your time!
>>
>> Ferdy
>>
>> On Sunday, November 10, 2013 5:22:01 AM UTC-6, Vibhu Rishi wrote:
>>>
>>> Do you have both versions of django installed ? That could cause the
>>> issue.
>>>
>>> I suggest that you make a virtual environment (
>>> https://pypi.python.org/pypi/virtualenv ) and do a pip install of django.
>>> This will let you work on different versions of django on the same machine.
>>>
>>> Vibhu
>>>
>>>
>>> On Sun, Nov 10, 2013 at 2:32 AM, Ferdy Rodríguez 
>>> wrote:

 Hi,

 I've been wanting to to test django 1.6, I'm installing this new release
 on a virtualenv. However, whenever a to django-admin.py startproject mysite
 I get the settings.py and urls.py from previous version (1.5). It even
 weirder that at creating an app django-admin.py startapp app I get the
 correct files.

 I've checked that I'm using django 1.6, as it is what I get by doing
 django.get_version() in the python shell.

 Does anybody knows what could be happening?

 --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to django-users...@googlegroups.com.
 To post to this group, send email to django...@googlegroups.com.
 Visit this group at http://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/cea3e499-7641-4275-b869-ba9cf3a7a804%40googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>>
>>> --
>>> Simplicity is the ultimate sophistication. - Leonardo da Vinci
>>> Life is really simple, but we insist on making it complicated. -
>>> Confucius
>>
>> --
>> 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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/332db6f6-6c5e-45bb-ab1c-70731ee27497%40googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPiONwnenoOhkaU7DijrEQwv7kuHErp%3Dd--37RBOxLv2pTRPeQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
MLHIM VIP Signup: http://goo.gl/22B0U

Timothy Cook, MSc   +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3Vnnc8ADz66UDmzSXO8HqZiOVAMhgkEG9zEeazdWcBW-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.