Re: Advice: django deploy vps error 502

2017-02-28 Thread Antonis Christofides
Hello,

502 usually means the backend isn't running. After you finish the test, has the
backend stopped running? Does it continue to throw 502s? If that is the case,
I'm wildly guessing that processes might be growing and growing in memory and
being eventually killed, but I don't really know. Do you have DEBUG = False?
Does uwsgi write something in its log? Does the system write something in the
syslog?

Regards,

Antonis

Antonis Christofides
http://djangodeployment.com


On 02/28/2017 10:49 PM, carlos wrote:
> Hi, all 
> i have one vps for one application,
>
>  vps description
>
> 16GB RAM
> 8 core processor
> 160 GB SSD
> 6TB Transfer
>
> ok, i am using, uwsgi(2.0.14), nginx(1.10), mysql(5.6 )and ubuntu 16.04 LTS
> this site working well when is visited or hits 1k even 6k, but when visited
> 10k or 12k
> raiser error 502,
>
> When I do a test of ab like these command line
> ab -k -c 350 -n 2 mydomain.com/ 
> again raiser the error 502 in almost pages
>
> these are configs all, wsgi, nginx
>
>  uwsgi script in /etc/uwsgi/app-availabre/website.ini -
> http://pastebin.com/vQW47WGb
>
>  nginx conf in /etc/nginx/nginx.conf  --
> http://pastebin.com/5BsWWaps
>
> - nginx vhost for my website mydpmain 
> http://pastebin.com/bMPvmrwR
>
> How can I do so that the site does not throw the error?
>
> Are the settings correct?
>
> How can i know the layer support the vps?
>
> In nginx how to stop the ab test, if many people do the test the web site
> throws the error 502 ngixn
>
> I would appreciate it if someone gave me an idea or advice to configure better
> when there is high traffic or are doing ab test or another benchmarking test
>
> cheers
>
> -- 
> att.
> Carlos Rocha
> -- 
> 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/CAM-7rO1u-ih5pd9b2AEEDLBJRL7DUvhVDs9hfZjpyGH_fHKJbQ%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.

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


database update after paypal payment

2017-02-28 Thread agoulouzegouna
hello! I am trying to update my database after paypal has received  the 
payment from customer. The problem is that I don't really know to do it. 
This is what I am doing now

here is my model

*class SubmitDoc(models.Model):*
*Student = 'stu'*
*Professional = 'Pro'*

*Status_CHOICES = (*
*(Student, 'Stu'),*
*(Professional, 'Pro'),*
   
*)*

*firstName = models.CharField(max_length =100)*
*lastName = models.CharField(max_length =100)*
*email = models.EmailField()*
*Stud_status = models.CharField(*
*max_length=3,*
*choices=Status_CHOICES,*
*default=Student,*
*)*
*uploadDoc = models.FileField(upload_to='documents/%Y/%m/%d/')   *
*comment = models.TextField()*
*created_on = models.DateTimeField(auto_now_add=True, editable=False)*
*paid = models.BooleanField(default=False)*
*finished_read = models.BooleanField(default=False)*
*read_by = models.CharField(max_length = 100, default="none")*

This is my view function to handle the forms that are submitted

def newSubmit(request):
save= False
form = SubmitDocForm(request.POST, request.FILES)
com =0
compteur=0
message ="bon"
solution = ""
counted=0
stud = False
amount_stu = 0.02
amount_pro = 0.03

   
if form.is_valid():
submitDoc = SubmitDoc()
submitDoc.firstName = form.cleaned_data['firstName'] 
submitDoc.lastName = form.cleaned_data['lastName']
submitDoc.email = form.cleaned_data['email']
submitDoc.Stud_status = form.cleaned_data['Stud_status']
submitDoc.uploadDoc = form.cleaned_data['uploadDoc'] 
# submitDoc.like = form.cleaned_data["like"]  
submitDoc.comment = form.cleaned_data['comment']
submitDoc.save()
save = True
# data = request.FILES["uploadDoc"]
pathy = submitDoc.uploadDoc.path
solution= get_docx_text(pathy)
counted = len(solution.split())
type_of_doc =  form.cleaned_data['Stud_status']

if  form.cleaned_data['Stud_status'] == "on":
stud = True
totals = round(counted*0.02, 2)
else:
stud = False
totals = round(counted *0.03, 2)

else:
form = SubmitDocForm()
 
return render(request, 'francais/saved.html', locals())

My problem is that I would like to update the database, the "*   paid = 
models.BooleanField(default=False)" ** field to true after the payment is 
received from paypal.*

*Here is how I redirect the user to paypal for payment:*

*https://www.paypal.com/cgi-bin/webscr; method="post">   http://www.example.com/order/21/;> http://www.example.com/thank-you;> 
 *

 

*Please help me to change the paid field to "True".*

-- 
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/211bcb0e-23aa-470f-9874-7d9c281398ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Advice: django deploy vps error 502

2017-02-28 Thread carlos
Hi, all
i have one vps for one application,

 vps description

16GB RAM
8 core processor
160 GB SSD
6TB Transfer

ok, i am using, uwsgi(2.0.14), nginx(1.10), mysql(5.6 )and ubuntu 16.04 LTS
this site working well when is visited or hits 1k even 6k, but when visited
10k or 12k
raiser error 502,

When I do a test of ab like these command line
ab -k -c 350 -n 2 mydomain.com/
again raiser the error 502 in almost pages

these are configs all, wsgi, nginx

 uwsgi script in /etc/uwsgi/app-availabre/website.ini -
http://pastebin.com/vQW47WGb

 nginx conf in /etc/nginx/nginx.conf  --
http://pastebin.com/5BsWWaps

- nginx vhost for my website mydpmain 
http://pastebin.com/bMPvmrwR

How can I do so that the site does not throw the error?

Are the settings correct?

How can i know the layer support the vps?

In nginx how to stop the ab test, if many people do the test the web site
throws the error 502 ngixn

I would appreciate it if someone gave me an idea or advice to configure
better when there is high traffic or are doing ab test or another
benchmarking test

cheers

-- 
att.
Carlos Rocha

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


intergate python file to work to a value recover by rest api

2017-02-28 Thread Selma
Hi
I have a mobility code of 2 points, I have already a map with a marker, I 
would like to integrate the mobility code (mobility for x and y) to the 
marker 

-- 
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/a57efd65-a26d-4b08-a370-8f18f8a147d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


attribute required and error XML

2017-02-28 Thread chun974
Hi all,
I have  an problem. When I use the django library  form, It create an 
attribute "required" for an input. But when I look on my explorer (firefox 
or chrome or IE) i have a XML error. 

"XML parsing error: malformed".

this is my code : 
"
class LoginForm(forms.Form):
email = forms.EmailField(label='Courriel :')
password = forms.CharField(label='Mot de passe :',
widget = forms.PasswordInput)  
def clean(self):
cleaned_data = super (LoginForm,self).clean()
email = cleaned_data.get("email")
password = cleaned_data.get("password")
if email and password:
if password != 'bob' or email != 'b...@bob.fr' :
raise forms.ValidationError("Adresse de courriel ou mot de 
passe erroné.")   
return cleaned_data
"

this is my déclaration for XML and doctype : 
"



http://www.w3.org/1999/xhtml; xml:lang="fr"> "

I can put "required=False" and it's OK, but I want that my input is required 
(required=True it's not OK)
XML don't accept that required  attribute is alone, whithout "= someting".

If someone has had this problem? 

Django 1.10
Firefox last update

-- 
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/8cb6a10b-fc89-4f9a-814e-a905ea9eef6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Handle uncaught exceptions?

2017-02-28 Thread Александр Христюхин (roboslone)
Hi, what you need is a middleware with process_exception method. Be sure that 
it's the last one in MIDDLEWARE setting.
https://docs.djangoproject.com/en/1.10/topics/http/middleware/#process-exception
 



> On 28 Feb 2017, at 08:57, Chillar Anand  wrote:
> 
> In staging server, for staff users, I am trying to show actual exception even 
> if DEBUG is False.
> 
> I am using this wsgi file 
>  for 
> it. However, handle_uncaught_exception method is not getting called?
> 
> Any help on how to fix this?
> 
> -- 
> 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/fddd8515-bf54-4e73-94e4-e0f9afe42188%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/7D869CB5-A625-4FB8-AEE2-4FE96B7074E5%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Handle uncaught exceptions?

2017-02-28 Thread Chillar Anand
In staging server, for staff users, I am trying to show actual exception 
even if DEBUG is False.

I am using this wsgi file 
 for 
it. However, handle_uncaught_exception method is not getting called?

Any help on how to fix this?

-- 
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/fddd8515-bf54-4e73-94e4-e0f9afe42188%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: What's the best way to create a reusable pagination template?

2017-02-28 Thread fabrixxm
Yep. My solution is a custom template tag

from django.template.defaulttags import register
from urllib.parse import urlencode

@register.simple_tag(takes_context=True)
def querystringmod(context, *args):
"""Modify current querystring:
 {% querystringmod name value [name value [...]] %}
"""
if (len(args) % 2) !=0:
args.append("")
request = context['request']
current_qs = request.GET.dict()
current_qs.update(dict([ (args[n], args[n+1]) for n in range(0, len(args
), 2) ]))
return urlencode(current_qs)

in template

previous



-- 
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/31ec3240-cee2-41b5-acd0-f4e05d41fb61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.