django not logging errors to file when running on nginx
I'm running a django app with uwsgi and nginx. I'm trying to have to django log some 500 errors so I can debug an issue but for some reason it is not writing to the file I've specified when I access my app at its domain. The logging works fine when I manually test the app using uwsgi.
here's my nginx.conf
#nginx.conf
upstream django {
# connect to this socket
server unix:/tmp/uwsgi.sock; # for a file socket
#server 127.0.0.1:8001; # for a web port socket
}
server {
listen 80 default_server;
server_name mysite.org
return 301 https://$server_name$request_uri;
}
server {
# the port your site will be served on
#listen 80 default_server;
#listen 8000;
listen 443 ssl;
root /opt/apps/site-env/trust_site;
# the domain name it will serve for
server_name mysite.org
#Max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /opt/apps/site-env/site/media; # your
Django project's media files
}
location /static {
alias /opt/apps/site-env/site/static; # your Django
project's static files
}
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params;
proxy_pass_header X-CSRFToken;
#proxy_set_header X-Forwarded-Proto https;
#proxy_set_header HOST $host;
}
}
help anyone?
/r/django
https://redd.it/6btiwt
I'm running a django app with uwsgi and nginx. I'm trying to have to django log some 500 errors so I can debug an issue but for some reason it is not writing to the file I've specified when I access my app at its domain. The logging works fine when I manually test the app using uwsgi.
here's my nginx.conf
#nginx.conf
upstream django {
# connect to this socket
server unix:/tmp/uwsgi.sock; # for a file socket
#server 127.0.0.1:8001; # for a web port socket
}
server {
listen 80 default_server;
server_name mysite.org
return 301 https://$server_name$request_uri;
}
server {
# the port your site will be served on
#listen 80 default_server;
#listen 8000;
listen 443 ssl;
root /opt/apps/site-env/trust_site;
# the domain name it will serve for
server_name mysite.org
#Max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /opt/apps/site-env/site/media; # your
Django project's media files
}
location /static {
alias /opt/apps/site-env/site/static; # your Django
project's static files
}
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params;
proxy_pass_header X-CSRFToken;
#proxy_set_header X-Forwarded-Proto https;
#proxy_set_header HOST $host;
}
}
help anyone?
/r/django
https://redd.it/6btiwt
reddit
django not logging errors to file when running on nginx • r/django
I'm running a django app with uwsgi and nginx. I'm trying to have to django log some 500 errors so I can debug an issue but for some reason it is...
Tutorial: How to determine revenue-maximizing prices in Python
https://www.datascience.com/resources/notebooks/finding-optimal-pricing-to-maximize-revenue-in-python
/r/pystats
https://redd.it/6bpyom
https://www.datascience.com/resources/notebooks/finding-optimal-pricing-to-maximize-revenue-in-python
/r/pystats
https://redd.it/6bpyom
Datascience
Developing a Pricing Strategy to Maximize Revenue
Senior Data Scientist Jean-René Gauthier explains how dynamic pricing can optimize revenue using data science.
How to protect urls
I want to protect my media files, and have done this like so, in url.py:
from django.conf.urls import patterns, include, url
from django.contrib.auth.decorators import login_required
from django.views.static import serve
from django.conf import settings
@login_required
def protected_serve(request, path, document_root=None, show_indexes=False):
return serve(request, path, document_root, show_indexes)
urlpatterns = patterns('',
url(r'^%s(?P<path>.*)$' % settings.MEDIA_URL[1:], protected_serve, {'document_root': settings.MEDIA_ROOT}),
)
and this works, so i can only acces the media file if i am logged in. But i want to be able to grant acces to each file, so not only do you need to login you also need to have acces right to this file, so i made this model.
from django.contrib.auth.models import User
from upload import models as upload_models
class UserVideo(models.Model):
user = models.ForeignKey(User,related_name='_myfiles')
file = models.ForeignKey(upload_models.Document)
def __str__(self):
return u'%s - %s' % (self.user, self.file)
its a list of users and what video each user can see, so i can do something like:
myfiles = request.user._myfiles.all()
and get all the files.
how do i protect the url, so instead of checking if i am logged in, it also check if i have acces to it in this model? is this possible to do in the url.py ?
/r/djangolearning
https://redd.it/6bvae0
I want to protect my media files, and have done this like so, in url.py:
from django.conf.urls import patterns, include, url
from django.contrib.auth.decorators import login_required
from django.views.static import serve
from django.conf import settings
@login_required
def protected_serve(request, path, document_root=None, show_indexes=False):
return serve(request, path, document_root, show_indexes)
urlpatterns = patterns('',
url(r'^%s(?P<path>.*)$' % settings.MEDIA_URL[1:], protected_serve, {'document_root': settings.MEDIA_ROOT}),
)
and this works, so i can only acces the media file if i am logged in. But i want to be able to grant acces to each file, so not only do you need to login you also need to have acces right to this file, so i made this model.
from django.contrib.auth.models import User
from upload import models as upload_models
class UserVideo(models.Model):
user = models.ForeignKey(User,related_name='_myfiles')
file = models.ForeignKey(upload_models.Document)
def __str__(self):
return u'%s - %s' % (self.user, self.file)
its a list of users and what video each user can see, so i can do something like:
myfiles = request.user._myfiles.all()
and get all the files.
how do i protect the url, so instead of checking if i am logged in, it also check if i have acces to it in this model? is this possible to do in the url.py ?
/r/djangolearning
https://redd.it/6bvae0
reddit
How to protect urls • r/djangolearning
I want to protect my media files, and have done this like so, in url.py: from django.conf.urls import patterns, include, url from...
Top 15 Python Libraries for Data Science in 2017
https://activewizards.com/blog/top-15-libraries-for-data-science-in-python/
/r/Python
https://redd.it/6bvwvn
https://activewizards.com/blog/top-15-libraries-for-data-science-in-python/
/r/Python
https://redd.it/6bvwvn
ActiveWizards: data science and engineering lab
Top 15 Python Libraries for Data Science in 2017 | ActiveWizards: data science and engineering lab
In this article we wanted to outline some of the most useful Python libraries for data scientists and engineers based on our experience.
Using Flask for big applications as E-commerce
I've been using Flask for the last couple of years, but I just developed small applications for the companies that worked for.
I'm willing to develop a big e-commerce web system with Flask, but I don't know if it's gonna last. Based on my researches, Flask was never used on a application like that.
Well, shoud I try?
Thanks!
/r/flask
https://redd.it/6bwn2k
I've been using Flask for the last couple of years, but I just developed small applications for the companies that worked for.
I'm willing to develop a big e-commerce web system with Flask, but I don't know if it's gonna last. Based on my researches, Flask was never used on a application like that.
Well, shoud I try?
Thanks!
/r/flask
https://redd.it/6bwn2k
reddit
Using Flask for big applications as E-commerce • r/flask
I've been using Flask for the last couple of years, but I just developed small applications for the companies that worked for. I'm willing to...
Custis Trail Bike Count Forecaster
https://georgetsilva.github.io/posts/custis-trail-bike-count-forecaster/
/r/pystats
https://redd.it/6bqklv
https://georgetsilva.github.io/posts/custis-trail-bike-count-forecaster/
/r/pystats
https://redd.it/6bqklv
Data EconoScientist
Custis Trail Bike Count Forecaster
In this article, I will step through the process of forecasting the number of bicycles traveling on the Custis trail daily by using sophisticated machine learning techniques. Originally, I was planni
What if range did not exist?
https://aroberge.blogspot.se/2017/05/what-if-range-did-not-exist.html
/r/Python
https://redd.it/6bvrkk
https://aroberge.blogspot.se/2017/05/what-if-range-did-not-exist.html
/r/Python
https://redd.it/6bvrkk
aroberge.blogspot.co.uk
What if range did not exist?
Over the years, various proposals for new syntactic constructs have been put forward to supplement or replace the range() function for loop...
Exploring Turing Patterns with Python
http://www.degeneratestate.org/posts/2017/May/05/turing-patterns/
/r/Python
https://redd.it/6bygdw
http://www.degeneratestate.org/posts/2017/May/05/turing-patterns/
/r/Python
https://redd.it/6bygdw
reddit
Exploring Turing Patterns with Python • r/Python
3 points and 0 comments so far on reddit
Create an application with websockets and flask
https://tutorials.technology/tutorials/61-Create-an-application-with-websockets-and-flask.html
/r/flask
https://redd.it/6byzo7
https://tutorials.technology/tutorials/61-Create-an-application-with-websockets-and-flask.html
/r/flask
https://redd.it/6byzo7
what is form validation and why do i need to re-validate server side?
i was recently told that if I validate on the client-side, i should re-validate on the server side. My question is what constitutes form-validation and why do i need to validate on the server if it's already being done on the client-side?
context:
I used react in the front end to validate that there was input typed into a form. once input was entered , another component was rendered. my developer friend told me that if i'm validating on the client side, I should also validate on the server side. But what was I validating there that would need to be on the server side?
/r/flask
https://redd.it/6bzsfk
i was recently told that if I validate on the client-side, i should re-validate on the server side. My question is what constitutes form-validation and why do i need to validate on the server if it's already being done on the client-side?
context:
I used react in the front end to validate that there was input typed into a form. once input was entered , another component was rendered. my developer friend told me that if i'm validating on the client side, I should also validate on the server side. But what was I validating there that would need to be on the server side?
/r/flask
https://redd.it/6bzsfk
reddit
what is form validation and why do i need to re-validate... • r/flask
i was recently told that if I validate on the client-side, i should re-validate on the server side. My question is what constitutes...
[P] Google releases dataset of 50M vector drawings, open sources Sketch-RNN implementation.
https://quickdraw.withgoogle.com/data
/r/MachineLearning
https://redd.it/6c0cc4
https://quickdraw.withgoogle.com/data
/r/MachineLearning
https://redd.it/6c0cc4
Withgoogle
Quick, Draw! The Data
What would you do with 50,000,000 drawings made by real people on the internet?
Help: setup a workflow to create my content with vim
Hello ! I need your advices on a question I am asking myself since few weeks. I want to make my website (blog, comments, portfolio and resources, no CDN) and I was highly hyped for a static site generator.
Why ? Because this could allow me to write my content as files, and then push them on the server very easily. Plus, don't need to go on the admin panel. Problem ? I can't handle dynamic content (just comments for the moment) and I don't want to use a third-party that do it for me.
So I was hopping that someone could help me on this one, is there a way to have a a website using a database, but I push and update my content with files ?
/r/django
https://redd.it/6c2kw0
Hello ! I need your advices on a question I am asking myself since few weeks. I want to make my website (blog, comments, portfolio and resources, no CDN) and I was highly hyped for a static site generator.
Why ? Because this could allow me to write my content as files, and then push them on the server very easily. Plus, don't need to go on the admin panel. Problem ? I can't handle dynamic content (just comments for the moment) and I don't want to use a third-party that do it for me.
So I was hopping that someone could help me on this one, is there a way to have a a website using a database, but I push and update my content with files ?
/r/django
https://redd.it/6c2kw0
reddit
Help: setup a workflow to create my content with vim • r/django
Hello ! I need your advices on a question I am asking myself since few weeks. I want to make my website (blog, comments, portfolio and resources,...
Do i always need WTF forms?
Question is pretty self-explanatory. Do i always need it? I use ReactJS on the front-end, idk if that means anything at all.
/r/flask
https://redd.it/6bzv4m
Question is pretty self-explanatory. Do i always need it? I use ReactJS on the front-end, idk if that means anything at all.
/r/flask
https://redd.it/6bzv4m
reddit
Do i always need WTF forms? • r/flask
Question is pretty self-explanatory. Do i always need it? I use ReactJS on the front-end, idk if that means anything at all.
Jupyter Notebook: Little-Known Tricks!
https://blog.3blades.io/jupyter-notebook-little-known-tricks-b0866a558017
/r/IPython
https://redd.it/6c2hwm
https://blog.3blades.io/jupyter-notebook-little-known-tricks-b0866a558017
/r/IPython
https://redd.it/6c2hwm
3Blades Blog
Jupyter Notebook: Little-Known Tricks!
We’ve written before about the evolution of Project Jupyter, how the notebook is great for teams, and how it can be even used with Apache…
Post-Python Dissatisfaction Syndrome
Hello /r/Python,
First of all, this is a serious post and by no means I am trying to be humorous here. I suffer from post-Python dissatisfaction syndrome, that is, any other programming language seems just not as expressive, as powerful, and as beautiful as Python. I abstain from mentioning any names to start a flame war, but with many languages that I considered, popular-and-hype or old-and-traditional, that was how I felt.
I wanted to ask you if that's also the case for you, **and** whether you can give me some suggestions for a different programming language. I'm looking for a preferably (AOT) compiled language, although my chief concern is execution speed and the expressiveness of Python. Also, a mature or at least good enough ecosystem of libraries is equally important (for GUI at least).
I asked here because I wanted to hear Pythonistas' preferences for another Pythonic language, sorry if it's considered out-of-place. Feel free to contribute your own opinion on any other language that you consider to be Pythonic.
Thanks!
/r/Python
https://redd.it/6c1jnv
Hello /r/Python,
First of all, this is a serious post and by no means I am trying to be humorous here. I suffer from post-Python dissatisfaction syndrome, that is, any other programming language seems just not as expressive, as powerful, and as beautiful as Python. I abstain from mentioning any names to start a flame war, but with many languages that I considered, popular-and-hype or old-and-traditional, that was how I felt.
I wanted to ask you if that's also the case for you, **and** whether you can give me some suggestions for a different programming language. I'm looking for a preferably (AOT) compiled language, although my chief concern is execution speed and the expressiveness of Python. Also, a mature or at least good enough ecosystem of libraries is equally important (for GUI at least).
I asked here because I wanted to hear Pythonistas' preferences for another Pythonic language, sorry if it's considered out-of-place. Feel free to contribute your own opinion on any other language that you consider to be Pythonic.
Thanks!
/r/Python
https://redd.it/6c1jnv
reddit
Post-Python Dissatisfaction Syndrome • r/Python
Hello /r/Python, First of all, this is a serious post and by no means I am trying to be humorous here. I suffer from post-Python dissatisfaction...
Metaclasses in Python - one of my first blogposts. I'd like to hear some feedback.
https://millionintegrals.com/post/metaclasses-in-python/
/r/Python
https://redd.it/6c2x5u
https://millionintegrals.com/post/metaclasses-in-python/
/r/Python
https://redd.it/6c2x5u
Million Integrals
Metaclasses in Python
New release of Flask-REST-JSONAPI with new features, enhancements and bug fixes
http://flask-rest-jsonapi.readthedocs.io/en/latest/
/r/flask
https://redd.it/6c4kji
http://flask-rest-jsonapi.readthedocs.io/en/latest/
/r/flask
https://redd.it/6c4kji
reddit
New release of Flask-REST-JSONAPI with new features,... • r/flask
2 points and 0 comments so far on reddit
cannot get django-select2 working properly
I have a ModelMultipleChoiceField that I want to replace with something from django-select2. It is not working for some reason, and I can't find a good example to copy from, since it's apparently so easy to do!
Model (simplified):
class Ingredient(models.Model):
listed_name = models.CharField(max_length=50, unique=True)
class Combination(models.Model):
ingredients = models.ManyToManyField(Ingredient)
When I try in my fields.py the following:
class CombinationForm(forms.Form):
ingredients = forms.ModelMultipleChoiceField(queryset=Ingredient.objects.all(),
widget=ModelSelect2MultipleWidget(queryset=Ingredient.objects.all(), search_fields=['listed_name__icontains']))
I get an empty widget on my webpage. When I try just setting
widget=Select2MultipleWidget()
I just get the usual Django widget, correctly populated with the Ingredient objects.
I cannot figure out what else I should be trying. I am using a forms.Form rather than a ModelForm because I have a validator, and I am under the impression that including it means that I would have to custom define my Field anyway.
I have jQuery on the page, added django-select2 to my installed apps, and included the urlPattern "url(r'^select2/', include('django_select2.urls'))," into my project's urls.py file just in case.
/r/djangolearning
https://redd.it/6bslnt
I have a ModelMultipleChoiceField that I want to replace with something from django-select2. It is not working for some reason, and I can't find a good example to copy from, since it's apparently so easy to do!
Model (simplified):
class Ingredient(models.Model):
listed_name = models.CharField(max_length=50, unique=True)
class Combination(models.Model):
ingredients = models.ManyToManyField(Ingredient)
When I try in my fields.py the following:
class CombinationForm(forms.Form):
ingredients = forms.ModelMultipleChoiceField(queryset=Ingredient.objects.all(),
widget=ModelSelect2MultipleWidget(queryset=Ingredient.objects.all(), search_fields=['listed_name__icontains']))
I get an empty widget on my webpage. When I try just setting
widget=Select2MultipleWidget()
I just get the usual Django widget, correctly populated with the Ingredient objects.
I cannot figure out what else I should be trying. I am using a forms.Form rather than a ModelForm because I have a validator, and I am under the impression that including it means that I would have to custom define my Field anyway.
I have jQuery on the page, added django-select2 to my installed apps, and included the urlPattern "url(r'^select2/', include('django_select2.urls'))," into my project's urls.py file just in case.
/r/djangolearning
https://redd.it/6bslnt
reddit
cannot get django-select2 working properly • r/djangolearning
I have a ModelMultipleChoiceField that I want to replace with something from django-select2. It is not working for some reason, and I can't find a...