Re: Django invoice generation system

2016-07-15 Thread James Schneider
On Jul 14, 2016 4:31 AM, "USMAN MALIK"  wrote:
>
> Hi. I'm new to django and i'm creating a buisness application for my
company. i want to generate a monthly invoice for every member in my
company and for this i have two models in which all the information is
stored. Is there a way to generate an automatic invoice based on the
information in these two models? kindly help me. thanks .
>

If you can code the logic necessary to extract the information needed on a
regular basis, then you can absolutely automate the task. Simple, recurring
cases can be handled by cron on *nix, and task scheduler on Windows. The
scripts are generally written as custom Django-admin commands, since you
usually need access to the ORM and your models for most tasks:

https://docs.djangoproject.com/en/1.9/howto/custom-management-commands/

More complicated tasks may require extra infrastructure like Celery. It
provides more flexibility, but is also more complicated to setup and manage:

http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html

Start with cron, and work your way up to Celery.

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


Re: Django session issue with mod_wsgi + apache

2016-07-15 Thread James Schneider
>
> Thanks for reply.
>
> I am using default value for django cache.
>
> We are building dynamic website so URL should be same for all user. But
Session can be used to display dynamic content.
>
> What are reason for such type behavior?
>
> And I am unable to reproduce the issue again.
>

Sometimes cases like this can be attributed to code that is not thread safe
and introduces race conditions. It may be that this issue will only appear
while the server is under high load.

Can you provide the view for your user profile (or the page you mentioned
where you saw the issue) and the template? The relevant urls.py may also be
useful.

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


Re: Django session issue with mod_wsgi + apache

2016-07-15 Thread Dipankar B
Thanks for reply.

I am using default value for django cache. 

We are building dynamic website so URL should be same for all user. But 
Session can be used to display dynamic content.

What are reason for such type behavior?

And I am unable to reproduce the issue again.

Please help me.




On Saturday, 16 July 2016 00:00:21 UTC+5:30, Dan Tagg wrote:
>
> Cacheing? 
> 1. Do Bob's and James's pages have different URLs
> 2. Have you configured your cacheing. if you are using it, to not reuse 
> components that could be confused?
> 3. Are you sending the correct cacheing directions to try and make sure 
> caches between your infrastructure and the user's screen are not making the 
> mistake.
>
> D
>
> On 15 July 2016 at 11:27, Dipankar B > 
> wrote:
>
>> Hello,
>>
>> I am working on Django Aplication . It has almost 350 users right now.
>>
>> Problem.
>>
>> Suppose we have a username bob and james.
>>
>> So, bob logged in and using our Django web application. But Sometimes 
>> bob's session is showing james account information. So bob is able to see 
>> James private data as we are using session (request.user ) to show user 
>> profile data.
>>
>> I am too much worried about this as it can completely ruin our 
>> application.
>>
>> Can you please tell me what is possible cause to such behavior.
>>
>> We are using 1.9.6.
>>
>> Please help.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/9bb086f2-8d30-4d97-af2c-921610d364df%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Wildman and Herring Limited, Registered Office: Sir Robert Peel House, 178 
> Bishopsgate, London, United Kingdom, EC2M 4NJ, Company no: 05766374
>

-- 
You received this message because you are subscribed 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/0934a340-c36b-4319-ae90-2f726cd6dab8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django invoice generation system

2016-07-15 Thread Amandeep Singh
Firstly you could create a function that uses these to models and renders a
html  or csv  format invoice. Then you could mail this to yourself. Once
the function is created then you could create a scheduled cron job using
celery or a even simple way would be to use crontab linux command with
monthly interval.

On 14-Jul-2016 5:01 pm, "USMAN MALIK"  wrote:

> Hi. I'm new to django and i'm creating a buisness application for my
> company. i want to generate a monthly invoice for every member in my
> company and for this i have two models in which all the information is
> stored. Is there a way to generate an automatic invoice based on the
> information in these two models? kindly help me. thanks .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ab6fca84-0cc7-4789-9e62-9d02cba01f6b%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/CAMi_2%3DEN6pfzhNoMn9MeYTUhCz50S6Z7UauVw8Y7ixxn5j2s%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Help with django form an ajax, error 500

2016-07-15 Thread Elros Romeo
Hi, i hope you can help me, im trying to make a django post form without 
reloading the page using ajax, but im getting error 500 when submit, can 
you help me to fix this, this is my code:

*models.py*

class ProductoConcepto(models.Model):
producto = models.ForeignKey(Producto)
orden = models.ForeignKey(Cobro)
cantidad = models.FloatField()


*urls.py*

from django.conf.urls import patterns, include, url
from django.contrib import admin
from cobro import views

urlpatterns = [
url(r'^cobro/agregar_concepto/$', views.addconcept_product, 
name='add_concepto'),
]

*views.py*


def addconcept_product(request):

if request.method == 'POST':

if form.is_valid():
producto = request.POST['producto']
orden = request.POST['orden']
cantidad = request.POST['cantidad']

ProductoConcepto.objects.create(producto=producto, orden=orden, 
cantidad=cantidad)

return HttpResponse('')

*template*






×
Cerrar

Agregar nuevo concepto


Datos de concepto a agregar:


{% csrf_token %}
{{form2.as_p}}

















$(document).on('submit', '#formulario-modal', function(e){
e.preventDefault();
$.ajax ({
type: 'POST',
url: '{% url 'add_concepto' %}',
data: {
producto: $('#id_producto').val(),
orden: $('#id_orden').val(),
cantidad: $('#id_cantidad').val(),
csrfmiddlewaretoken: '{{ csrf_token }}',
},
sucess:function(){
alert("OK");
}
})
});



this is the error:  POST http://127.0.0.1:8000/cobro/agregar_concepto/ 500 
(Internal Server Error)

-- 
You received this message because you are subscribed 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/f17e5677-4401-41e4-a928-326a23b3c6fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django session issue with mod_wsgi + apache

2016-07-15 Thread Dan Tagg
Cacheing?
1. Do Bob's and James's pages have different URLs
2. Have you configured your cacheing. if you are using it, to not reuse
components that could be confused?
3. Are you sending the correct cacheing directions to try and make sure
caches between your infrastructure and the user's screen are not making the
mistake.

D

On 15 July 2016 at 11:27, Dipankar B  wrote:

> Hello,
>
> I am working on Django Aplication . It has almost 350 users right now.
>
> Problem.
>
> Suppose we have a username bob and james.
>
> So, bob logged in and using our Django web application. But Sometimes
> bob's session is showing james account information. So bob is able to see
> James private data as we are using session (request.user ) to show user
> profile data.
>
> I am too much worried about this as it can completely ruin our application.
>
> Can you please tell me what is possible cause to such behavior.
>
> We are using 1.9.6.
>
> Please help.
>
> --
> You received this message because you are subscribed 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/9bb086f2-8d30-4d97-af2c-921610d364df%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: Sir Robert Peel House, 178
Bishopsgate, London, United Kingdom, EC2M 4NJ, Company no: 05766374

-- 
You received this message because you are subscribed 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/CAPZHCY4%3DRXY4GH21YdcT58375kwER5oC2CfoAED-P_wwHZMYRw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Dynamic ModelAdmin Field

2016-07-15 Thread Derek
Why not use custom methods on your model?  These can effectively act as 
extra properties:



*https://docs.djangoproject.com/en/1.9/topics/db/models/#model-methods*(this 
is assuming you do not want to store any data of course... otherwise you 
will need to give a more concrete example of what you want to do)

On Thursday, 14 July 2016 17:29:38 UTC+2, Bernat Bonet wrote:
>
> I need to add dynamic fields to ModelAdmin that are not part of the Model.
>
> Models:
>
> product: cod, des
> product_categories: cat, val
>
> I want to add val1, val2 in ProductAdmin
>
> Thanks
>
>
>

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


Code review and perfomance tips

2016-07-15 Thread Горобец Дмитрий
Hello, everybody.

I'm working on one project where I need to render cities on the page in 1-4 
columns like this. I'm rendering cities using 'regroup' filter:

A D   M U
AberdeenDanbury   MacombUkiah
Akron Delano   Mandan   Urbana
Manhattan

BH P W
BabylonHaledon   Pace   Waipio
BangorHanover   Walker

C   I   R
Calhoun   Indiana  Raleigh
Calipatria   Irondale Ridge
Cheval Riverdale

Main part of code looks:

def get_columns(location):
qs = Location.objects.filter(parent=location, active=True)
qs = qs.annotate(first_char=Upper(Substr('name', 1, 1)))
locations = qs.values()

first_chars = qs.distinct('first_char').order_by('first_char')
first_chars = first_chars.values_list('first_char', flat=True)

first_chars_count = len(first_chars)
num_of_columns = 4 if (first_chars_count / 4) >= 1 else first_chars_count
chars_per_column = math.ceil(first_chars_count / num_of_columns)

start = 0
stop = chars_per_column

for i in range(num_of_columns):
yield [location for location in locations 
   if location['first_char'] in first_chars[start:stop]]

start += chars_per_column
stop += chars_per_column



It can be rewritten using QuerySet filter, but this approach adds more queries 
in database:


def get_columns(location):
qs = Location.objects.filter(parent=location, active=True)
qs = qs.annotate(first_char=Upper(Substr('name', 1, 1)))

first_chars = qs.distinct('first_char').order_by('first_char')
first_chars = first_chars.values_list('first_char', flat=True)

first_chars_count = len(first_chars)
num_of_columns = 4 if (first_chars_count / 4) >= 1 else first_chars_count
chars_per_column = math.ceil(first_chars_count / num_of_columns)

start = 0
stop = chars_per_column

for i in range(num_of_columns):
yield qs.filter(first_char__in=first_chars[start:stop])

start += chars_per_column
stop += chars_per_column


Which is better? Filter using list comprehension or using queryset filter? 


Thanks.


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


Re: Django PostGis BUG?

2016-07-15 Thread Tim Graham
This query is also duplicated on Trac: 
https://code.djangoproject.com/ticket/26893 (closed as "worksforme").

For future reference, please ask "is it a bug?" questions on django-users 
and wait for confirmation that it is a bug before creating a Trac ticket.

On Friday, July 15, 2016 at 6:26:27 AM UTC-4, Jani Tiainen wrote:
>
> Hi,
>
> Could you verify what your database settings really are for example 
> printing them out at the end of settings.py. (Or in any view import your 
> settings to see that values really are what you expect.)
>
> On Wed, Jul 13, 2016 at 7:13 PM, > 
> wrote:
>
>> I'm trying to create my database tables (*python manage.py migrate*) 
>> using Postgis. However it fails because the driver try to connect do 
>> default database "postgres" which is not my default name. I'm using 
>> django==1.8 and psycopg2==2.6.2 
>>
>> If i look the documentation of psycopg (
>> http://initd.org/psycopg/docs/module.html) The basic connection 
>> parameters are:
>>
>> dbname – the database name (only in the dsn string)database – the database 
>> name (only as keyword argument)user – user name used to authenticate
>> password – password used to authenticate
>> host – database host address (defaults to UNIX socket if not provided)
>> port – connection port number (defaults to 5432 if not provided)
>>
>> Here is my database connection: 
>>
>> DATABASES = {
>>  'default': {
>>  'ENGINE': 'django.contrib.gis.db.backends.postgis', 
>>  'NAME': '',
>>  'USER': '',
>>  'PASSWORD': '',
>>  'HOST':  ‘bdsn15qbq8xaqoa-postgresql.services.clever-cloud.com'
>>  'PORT': '5432', 
>>  
>> 'URI':'postgis://myuser:mypassw...@bdsn15qbq8xaqoa-postgresql.services.clever-cloud.com:5432/bdsn15qbq8xaqoa'}}
>>
>> I have added some trace to the connexion and as we can see, the driver 
>> uses *postgres* as name.
>>
>> [('dbname', '**postgres**'), ('user', 'myuser'), ('password', 'mypassword'), 
>> ('host', 'bdsn15qbq8xaqoa-postgresql.services.clever-cloud.com'), ('port', 
>> '5432’)]
>>
>> After some research, i have edited the file :
>>
>>  *vi django/db/backends/postgresql_psycopg2/base.py*
>>
>>
>> Function : 
>>
>>
>> def get_connection_params(self):
>>
>> settings_dict = self.settings_dict
>>
>> # None may be used to connect to the default 'postgres' db
>>
>> if settings_dict['NAME'] == '':
>>
>> from django.core.exceptions import ImproperlyConfigured
>>
>> raise ImproperlyConfigured(
>>
>> "settings.DATABASES is improperly configured. "
>>
>> "Please supply the NAME value.")
>>
>> conn_params = {
>>
>> 'database': settings_dict['NAME'] or 'postgres',
>>
>> }
>>
>> print settings_dict
>>
>> conn_params.update(settings_dict['OPTIONS'])
>>
>> conn_params.pop('isolation_level', None)
>>
>> if settings_dict['USER']:
>>
>> conn_params['user'] = settings_dict['USER']
>>
>> if settings_dict['PASSWORD']:
>>
>> conn_params['password'] = force_str(settings_dict['PASSWORD'])
>>
>> if settings_dict['HOST']:
>>
>> conn_params['host'] = settings_dict['HOST']
>>
>> if settings_dict['PORT']:
>>
>> conn_params['port'] = settings_dict['PORT']
>>
>> return conn_params
>>
>>
>> *AND ADDED : *
>>
>>
>> *   if settings_dict['DBNAME']:*
>>
>> *conn_params['dbname'] = settings_dict['DBNAME']*
>>
>> Now if i relaunch the database creation : python manage.py migrate it is 
>> working fine using the good connection URI. 
>>
>> [('dbname', '**mydatabase**'), ('user', 'myuser'), ('password', 
>> 'mypassword'), ('host', 
>> 'bdsn15qbq8xaqoa-postgresql.services.clever-cloud.com'), ('port', '5432’) 
>>
>> It is a bug ? 
>>
>> Thanks a lot 
>> Christophe
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/d57803ab-eeb1-4f5a-a0ca-2725730178a7%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Jani Tiainen
>
> - Well planned is half done, and a half done has been sufficient before...
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google

Re: deploy django with nginx

2016-07-15 Thread Javier Guerra Giraldez
On 15 July 2016 at 11:47, 1351552...@qq.com <1351552...@qq.com> wrote:
> and with the message in file /var/log/nginx/error.log :
> connect() to unix:///home/wangwei/yaohang/yaohang.sock failed (13:
> Permission denied


check under what user is running nginx, and make sure that it has r/w
permissions on that socket

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


Re: deploy django with nginx

2016-07-15 Thread Rafael E. Ferrero
I used this link without any trouble
https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-14-04


Rafael E. Ferrero

2016-07-15 7:47 GMT-03:00 1351552...@qq.com <1351552...@qq.com>:

> hi everyone:
>
> I am tring to deploy my site by nginx and uwagi
> in my project yaohang,i have these files:
>
> #yaohang_uwsgi.ini
> [uwsgi]
> socket = :8001
> chmod-socket= 664
> master = true
> module = yaohang_uwsgi
> processes = 8
> listen = 120
> enable-threads = true
> daemonize = /home/wangwei/yaohang/yaohang_uwsgi.log
> pidfile = /home/wangwei/yaohang/yaohang_uwsgi.pid
> pythonpath = /home/wangwei/yaohang/
> pythonpath = /home/wangwei/yaohang/yaohang_uwsgi
> pythonpath = /home/wangwei/yaohang/yaohang
> buffer-size = 32768
> reload-mercy = 8
> vacuum = true
>
> #yaohang_uwsgi.py
> import os
> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "yaohang.settings")
>
> from django.core.wsgi import get_wsgi_application
> application = get_wsgi_application()
>
> #yaohang_uwsgi.conf
> server {
> listen  8000;
> server_name192.168.70.32; # this is my server's addr
> charset UTF-8;
>
> client_max_body_size 75M;
>
> location / {
> include uwsgi_params;
> uwsgi_pass 127.0.0.1:8001;
> uwsgi_read_timeout 2;
> }
> location /static {
> expires 30d;
> autoindex on;
> add_header Cache-Control private;
> alias /home/wangwei/yaohang/static/;
> }
> }
>
> run nginx and
> >>uwsgi --http 192.168.70.32:8001 --wsgi-file yaohang_uwsgi.py
>
> and then by my client browser:192.168.70.32:8000
> it show:502 Bad Gateway
>
> and with the message in file /var/log/nginx/error.log :
> connect() to unix:///home/wangwei/yaohang/yaohang.sock failed (13:
> Permission denied) while connecting to upstream, client: 192.168.71.3,
> server: 192.168.70.32, request: "GET / HTTP/1.1", upstream:
> "uwsgi://unix:///home/wangwei/yaohang/yaohang.sock:", host: "
> 192.168.70.32:8000"
>
> who can tell me where is wrong?
>
> thank you!
>
> wblueboat
>
>
>
> --
> You received this message because you are subscribed 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/201607151847061918789%40qq.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/CAJJc_8UxOJ0j%3DoCTyho744Qvie8U7NiMTZ%3D4OmC16--_j5aaNw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django session issue with mod_wsgi + apache

2016-07-15 Thread Dipankar B
Hello,

I am working on Django Aplication . It has almost 350 users right now.

Problem.

Suppose we have a username bob and james.

So, bob logged in and using our Django web application. But Sometimes bob's 
session is showing james account information. So bob is able to see James 
private data as we are using session (request.user ) to show user profile 
data.

I am too much worried about this as it can completely ruin our application.

Can you please tell me what is possible cause to such behavior.

We are using 1.9.6.

Please help.

-- 
You received this message because you are subscribed 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/9bb086f2-8d30-4d97-af2c-921610d364df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


deploy django with nginx

2016-07-15 Thread 1351552...@qq.com
hi everyone:

I am tring to deploy my site by nginx and uwagi
in my project yaohang,i have these files:

#yaohang_uwsgi.ini
[uwsgi] 
socket = :8001 
chmod-socket= 664
master = true 
module = yaohang_uwsgi 
processes = 8 
listen = 120 
enable-threads = true 
daemonize = /home/wangwei/yaohang/yaohang_uwsgi.log 
pidfile = /home/wangwei/yaohang/yaohang_uwsgi.pid 
pythonpath = /home/wangwei/yaohang/ 
pythonpath = /home/wangwei/yaohang/yaohang_uwsgi 
pythonpath = /home/wangwei/yaohang/yaohang 
buffer-size = 32768 
reload-mercy = 8 
vacuum = true

#yaohang_uwsgi.py
import os 
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "yaohang.settings") 

from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application()

#yaohang_uwsgi.conf
server { 
listen  8000;
server_name192.168.70.32; # this is my server's addr
charset UTF-8; 

client_max_body_size 75M; 

location / { 
include uwsgi_params; 
uwsgi_pass 127.0.0.1:8001; 
uwsgi_read_timeout 2; 
}
location /static { 
expires 30d; 
autoindex on; 
add_header Cache-Control private; 
alias /home/wangwei/yaohang/static/; 
} 
}   

run nginx and 
>>uwsgi --http 192.168.70.32:8001 --wsgi-file yaohang_uwsgi.py

and then by my client browser:192.168.70.32:8000
it show:502 Bad Gateway

and with the message in file /var/log/nginx/error.log :
connect() to unix:///home/wangwei/yaohang/yaohang.sock failed (13: Permission 
denied) while connecting to upstream, client: 192.168.71.3, server: 
192.168.70.32, request: "GET / HTTP/1.1", upstream: 
"uwsgi://unix:///home/wangwei/yaohang/yaohang.sock:", host: "192.168.70.32:8000"

who can tell me where is wrong?

thank you!

wblueboat
 

-- 
You received this message because you are subscribed 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/201607151847061918789%40qq.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django PostGis BUG?

2016-07-15 Thread Jani Tiainen
Hi,

Could you verify what your database settings really are for example
printing them out at the end of settings.py. (Or in any view import your
settings to see that values really are what you expect.)

On Wed, Jul 13, 2016 at 7:13 PM,  wrote:

> I'm trying to create my database tables (*python manage.py migrate*)
> using Postgis. However it fails because the driver try to connect do
> default database "postgres" which is not my default name. I'm using
> django==1.8 and psycopg2==2.6.2
>
> If i look the documentation of psycopg (
> http://initd.org/psycopg/docs/module.html) The basic connection
> parameters are:
>
> dbname – the database name (only in the dsn string)database – the database 
> name (only as keyword argument)user – user name used to authenticate
> password – password used to authenticate
> host – database host address (defaults to UNIX socket if not provided)
> port – connection port number (defaults to 5432 if not provided)
>
> Here is my database connection:
>
> DATABASES = {
>  'default': {
>  'ENGINE': 'django.contrib.gis.db.backends.postgis',
>  'NAME': '',
>  'USER': '',
>  'PASSWORD': '',
>  'HOST':  ‘bdsn15qbq8xaqoa-postgresql.services.clever-cloud.com'
>  'PORT': '5432',
>  
> 'URI':'postgis://myuser:mypassw...@bdsn15qbq8xaqoa-postgresql.services.clever-cloud.com:5432/bdsn15qbq8xaqoa'}}
>
> I have added some trace to the connexion and as we can see, the driver
> uses *postgres* as name.
>
> [('dbname', '**postgres**'), ('user', 'myuser'), ('password', 'mypassword'), 
> ('host', 'bdsn15qbq8xaqoa-postgresql.services.clever-cloud.com'), ('port', 
> '5432’)]
>
> After some research, i have edited the file :
>
>  *vi django/db/backends/postgresql_psycopg2/base.py*
>
>
> Function :
>
>
> def get_connection_params(self):
>
> settings_dict = self.settings_dict
>
> # None may be used to connect to the default 'postgres' db
>
> if settings_dict['NAME'] == '':
>
> from django.core.exceptions import ImproperlyConfigured
>
> raise ImproperlyConfigured(
>
> "settings.DATABASES is improperly configured. "
>
> "Please supply the NAME value.")
>
> conn_params = {
>
> 'database': settings_dict['NAME'] or 'postgres',
>
> }
>
> print settings_dict
>
> conn_params.update(settings_dict['OPTIONS'])
>
> conn_params.pop('isolation_level', None)
>
> if settings_dict['USER']:
>
> conn_params['user'] = settings_dict['USER']
>
> if settings_dict['PASSWORD']:
>
> conn_params['password'] = force_str(settings_dict['PASSWORD'])
>
> if settings_dict['HOST']:
>
> conn_params['host'] = settings_dict['HOST']
>
> if settings_dict['PORT']:
>
> conn_params['port'] = settings_dict['PORT']
>
> return conn_params
>
>
> *AND ADDED : *
>
>
> *   if settings_dict['DBNAME']:*
>
> *conn_params['dbname'] = settings_dict['DBNAME']*
>
> Now if i relaunch the database creation : python manage.py migrate it is
> working fine using the good connection URI.
>
> [('dbname', '**mydatabase**'), ('user', 'myuser'), ('password', 
> 'mypassword'), ('host', 
> 'bdsn15qbq8xaqoa-postgresql.services.clever-cloud.com'), ('port', '5432’)
>
> It is a bug ?
>
> Thanks a lot
> Christophe
>
> --
> You received this message because you are subscribed 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/d57803ab-eeb1-4f5a-a0ca-2725730178a7%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Jani Tiainen

- Well planned is half done, and a half done has been sufficient before...

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


Re: Jet Admin Backend Prob with Google Analytics

2016-07-15 Thread Michael Schintler
Thank U very much solved the prob by 

Troque:
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))


PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))


So it works now. But the widget for GoogleAnalytics still not. I will find 
and solve that ;) 

But thx U helped me a lot.


Am Donnerstag, 14. Juli 2016 18:30:36 UTC+2 schrieb ludovic coues:
>
> You have no variable named PROJECT_DIR your file 
> pressmedia/pm/settings.py. 
> You might want to remove os.path.join as you already specify the full 
> path. 
>
> 2016-07-14 17:16 GMT+02:00 Michael Schintler  >: 
> > Hi all , 
> > 
> > I m sorry but new to Django and after some learning i came to Jet Admin 
> > Backend. All works fine excepting the "Google Analytics Widget". 
> > Could anybody help me ? 
> > 
> > I folowed absolutly this link 
> > 
> https://github.com/geex-arts/django-jet/blob/master/docs/dashboard_modules.rst
>  
> > 
> > but it s a prob with my Document root . When i set the absolute path to 
> the 
> > client_secrets.json i become this output 
> > 
> >  File 
> > 
> "/home/developer/webapps/machine2/django/lib/python3.5/importlib/__init__.py",
>  
>
> > line 126, in import_module 
> > return _bootstrap._gcd_import(name[level:], package, level) 
> >   File "", line 986, in _gcd_import 
> >   File "", line 969, in _find_and_load 
> >   File "", line 958, in 
> _find_and_load_unlocked 
> >   File "", line 673, in _load_unlocked 
> >   File "", line 662, in 
> exec_module 
> >   File "", line 222, in 
> > _call_with_frames_removed 
> >   File 
> "/home/developer/webapps/machine2/django/pressmedia/pm/settings.py", 
> > line 4, in  
> > JET_MODULE_GOOGLE_ANALYTICS_CLIENT_SECRETS_FILE = 
> > os.path.join(PROJECT_DIR, 
> > 
> '/home/developer/webapps/machine2/django/pressmedia/client_secrets.json') 
> > NameError: name 'PROJECT_DIR' is not defined 
> > 
> > 
> > Thanks a lot if someone has an answer for me. 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to django-users...@googlegroups.com . 
> > To post to this group, send email to django...@googlegroups.com 
> . 
> > Visit this group at https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/f8f30a8d-a3b4-45b5-ab24-39c0251eaa95%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
>
> Cordialement, Coues Ludovic 
> +336 148 743 42 
>

-- 
You received this message because you are subscribed 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/bc7a2f3a-1c53-40ca-a7a4-9d00be8bf3e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Document storage and data mining

2016-07-15 Thread Javier Guerra Giraldez
On 15 July 2016 at 00:02, Gary Roach  wrote:
> While - with the exception of the metafile - these are static files, we are
> talking about hundreds of documents. I do not think that storing them as
> static files will work. They have to be searchable. I assume that I need a
> model that will set up appropriate fields in the database (postgresql) This
> is where I stumble. I've looked at the Model.field reference but can't seem
> to come up with what I need or don't know what I'm looking at. The latter
> being the most probable.


do store the PDFs as static files.  just not in a single directory,
instead add one or two levels of subdirectories.  Alternatively, use
an Object Storage, like S3, for that (check django-storages [1] for an
easy way to do it).  To make them searchable, store the plain text of
the document in a TextField in the model, and add a full text index
(you can use Watson [2] to help with that).


[1] http://django-storages.readthedocs.io/en/latest/
[2] https://github.com/etianen/django-watson


-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFkDaoQ0WCe48gDP-atcLBLD4TsrA9%2BczAtSAPiD6%2BCaHijiSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.