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
[AF] Using SQLAlchemy dialects in Flask-SQLAlchemy

Dear Flask and SQLAlchemy experts: Is it OK to import the datatypes for PostgreSQL from sqlalchemy.dialects.postresql and replace what generic flask_sqlalchemy fields but still use the db.Column, for example:

`generic_field = db.Column(db.Text())`

with something like:

`pgsql_field = db.Column(VARCHAR())` ?

/r/flask
https://redd.it/6txueg
Is Flask Documentation enough?

Hi there, whenever someone asks about resources to learn Flask, Miguel Grinberg's flask tutorials are recommended. So, I was following Miguel's Flask Mega-tutorial, and even though I tried, I couldn't like it. It doesn't explain the details quite well, uses old technology (openID), at times is verbose. I really like Miguel's intentions and his openness to teach the topic. But, I am not impressed with the delivery of that specific tutorial, my question to you guys is - is Flask documentation enough to go deep into the intricacies of Flask and develop scalable apps?

I thought of making this post as I am getting a bit demotivated after going through Flask Mega-tutorial. I have taken Flask tutorials at Lynda, and some watched few video series on YouTube including Michael Herman's flask tutorial and they were really good.

I am aware Miguel will be updating his Flask-Mega tutorial this year so let's see how that goes?!

What's your opinion of Flask Documentation?

/r/flask
https://redd.it/6qxs3s
Who maintains PyPI and where and by whom is it hosted?

After reading this comment https://www.reddit.com/r/Python/comments/4jaaib/pypi_download_stats_have_stopped_working_again/d355dt6/
I started wondering where does PyPI actually lie? Who hosts the PyPI servers? Where are they physically localted? Who maintains and submits the code there? How can I trust what packages come out when I type install?

/r/Python
https://redd.it/6ug04h
Trying to get Django and chart.js to work.

I have the following coming from a template html.



<!DOCTYPE html>
<html lang='en'>
<meta http-equiv="content-type" content="text/html; charset=UTF8">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.4/Chart.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script language="JavaScript">
var ctx = document.getElementById("myChart");
var defaultLabels = JSON.parse('["2017-01-01", "2017-01-02", "2017-01-03", "2017-01-04", "2017-01-05", "2017-01-06", "2017-01-07"]');
var defaultData = JSON.parse('["12", "8", "4", "9", "18", "1", "4"]');
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: defaultLabels,
datasets: [{
lineTension: 0,
label: 'Activity Profile',
data: defaultData,
}]
}
})

</script>
</head>
<body>
<canvas id="myChart"></canvas>
</body>
</html>

I keep getting a "Uncaught TypeError: Cannot read property 'length' of null" error. I'm trying to plot a simple line chart using chart.js and django. Any pointers much appreciated.


/r/django
https://redd.it/6uesnc
Secure Flask API

I made a REST api to be used in an iOS app I created. Currently you can go to api.mysite.com/featured and it will display the JSON. How can I reject all requests that do not come from my iOS app?

/r/flask
https://redd.it/6umdwq
Best way to learn Python as a beginner?

Hey guys, have been shortly working through some tutorials on Python, but have never really gotten past the first hump.

Where should i turn to, being a complete beginner wanting to learn python?

/r/Python
https://redd.it/6uruoh
Django Autoreloader: hot reload files in browser for development (Linux)

The [django-autoreloader](https://github.com/synw/django-autoreloader) module is a simple management command that watch directories for file change and reloads the browser when a file changes. A list of directories to watch is declared in settings as well as some paths to exclude from reloading.

Limitation: it works only for Linux.

This has just been released. It was tested on python 2.7 / 3.5 with Django 1.11 and Firefox / Chromium. I would appreciate some feedback to ensure that it works as expected for other configurations than mine. I also share because this module is pretty useful to me and might help some other Django devs.

/r/django
https://redd.it/6up23j
[D] what happened with Distill? is it dead?

https://distill.pub/ was a great idea to innovate research publishing, however, it seems that the community never ended up adopting it.
Does anybody know if more publications will be published from the initial ones or is this project officially abandoned?


/r/MachineLearning
https://redd.it/6usqhc
[AF][Flask-Login] Refreshing page causes is_authenticated to fail

I'm setting up a login system with Flask-Login, and I set up an if statement in Jinja to write to the HTML if a user is logged in, and write "Not logged in." otherwise.

{% if current_user.is_authenticated %}
You are logged in as {{ current_user.get_username() }}.
{% else %}
You are not logged in.
{% endif %}

However, when I log in, it will show that it is logged in, but then when I refresh the page, it will sometimes say that it is not logged in, but upon another refresh, say that it is logged in. If I spam refreshes, it will be about 50/50 chance of being either. My suspicion is that its not actually logging me out, but the is_authenticated is resolving to false which might be causing the problem, but I am somewhat new to Flask so I don't know if I am missing something. Any help would be appreciated!

/r/flask
https://redd.it/6uubmb
DjangoCon help update!

Hello everyone!

You may remember I posted here a [about a month ago](https://www.reddit.com/r/django/comments/6fl9ml/hello_im_speaking_at_djangocon_this_year_and_want/) asking for your opinion on what I should do in my [DjangoCon talk](https://2017.djangocon.us/tutorials/from-0-to-100-in-django/). Well I am happy to say I collected a ton of information and opinions from everyone, and I wanted to thank the community as a whole for making my talk so successful!

A few different people had asked if the talk would be posted online at a later date, at the time I was unsure of this myself as DjangoCon has done some tutorials in the past, but not always. I found out this week that they will not be posting my tutorial (or any of the 2017 tutorials) this year. Rest assured that all of the talks will be posted as normal though!

---

Regardless the tutorial was a huge success and many of the people who came were incredibly happy to have a more detailed look at Django, instead of the usual "copy/paste this code and type this command" that some talks and tutorials provide. I have been asked by multiple different attendee's if I would be willing to release my slides and code (which I will be doing in a few days), however the largest part of the tutorial was a live coding and q/a section. This cannot really be replicated with a github repo. Instead I want to try and do the next best thing. Over the next few weeks I plan on release a series of blog posts (2 a week) called "0-100 in Django." These blog posts will cover everything I covered in the tutorial. It will be an indepth look at the polls tutorial, that goes even further than the DjangoProject website takes it.

We will talk about Models, Managers, Querysets, Migrations, CBV vs Functional Views, and even best practices for code. We will also add user authentication, unit testing, and so much more!

So if you were one of the people who wanted to go to DjangoCon, but just couldn't afford it please come by! The [first post is already available](https://medium.com/@jeremytiki/0-100-in-django-introduction-75a182637462), and number 2 will be up Monday and cover setting up the best Django environment possible.

/r/django
https://redd.it/6ullat