Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
PyCon Sale of Python Books / Online Courses

Educative and I are doing a sale of Python books and courses. I am putting all my books and courses on sale at 50% off for PyCon. Educative does online interactive courses and when you purchase a course, you get **lifetime access**.

Let's start with the Educative courses. To get them for 50% off, you just need to use the following coupons:

* For [Python 101](https://www.educative.io/collection/5663684521099264/5707702298738688) – **au-pycon-reddit-101**
* For [Python 201: Intermediate Python](https://www.educative.io/collection/5663684521099264/5693417237512192) – **au-pycon-reddit-201**

Educative is also putting their [Python 3: An interactive deep dive](https://www.educative.io/collection/10370001/5705097937944576) course on sale for 50% off if you use this coupon: **au-pycon-reddit-deepdive**

Finally they also gave me a coupon for one of other courses: [Coderust 2.0: Faster Coding Interview Preparation using Interactive Visualizations](https://www.educative.io/collection/5642554087309312/5679846214598656) - **au-pycon-reddit-coderust** (Note that this coupon is only 17% off though.

For the eBook (PDF, mobi, epub) versions of my books, I am also doing a 50% off sale on Leanpub:

* [Python 101](http://leanpub.com/python_101/) is free or pay what you want
* [Python 201: Intermediate Python](http://leanpub.com/python201/c/50percent)
* [wxPython Cookbook](http://leanpub.com/wxpythoncookbook/c/50percent)


/r/Python
https://redd.it/6bomkd
Programmatically create a user with python-social-auth

I'm using python-social-auth so that users can log in with their google accounts. However, rather than allowing users to register, I want to programmatically create users given an email associated with their google account. How can I do this?

Thanks!

/r/django
https://redd.it/6btkfo
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
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
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
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
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
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