Memoization in Python: How to Cache Function Results
https://dbader.org/blog/python-memoization#intro
/r/Python
https://redd.it/7eiqq0
https://dbader.org/blog/python-memoization#intro
/r/Python
https://redd.it/7eiqq0
dbader.org
Memoization in Python: How to Cache Function Results – dbader.org
Speed up your Python programs with a powerful, yet convenient, caching technique called “memoization.”
Building a CRUD application with Flask and SQLAlchemy
https://www.codementor.io/garethdwyer/building-a-crud-application-with-flask-and-sqlalchemy-dm3wv7yu2
/r/flask
https://redd.it/7bslae
https://www.codementor.io/garethdwyer/building-a-crud-application-with-flask-and-sqlalchemy-dm3wv7yu2
/r/flask
https://redd.it/7bslae
www.codementor.io
Building a CRUD application with Flask and SQLAlchemy | Codementor
In this tutorial, we'll walk through building a minimal web application using Flask. We'll use SQLAlchemy in conjunction with SQLite to store information about books.
username collisions
We are building a site where our users upload files. Django's API uses the 'username.'
When we handle registration we just use email. It seems that Django (or maybe it is AllAuth) just truncates the email to build the username:
email: name@gmail.com --> username: name
This is fine for the most part. And Django may even handle username collisions because because it actually works off of the ID and just displays 'username' for human friendly reasons (IDK).
The issue I foresee is as follows: If we build file paths based on username, e.g. all of user1's files are in files/user1, we have a potential collision because at this point, on say AWS S3 we are no longer using Django's (potential) collision handling.
TL DR: what happens if we have two users, one with username1@gmail.com and the other with username1@yahoo.com AND Django sets username to be a truncated email AND we build file paths off of username?
/r/django
https://redd.it/7emdcg
We are building a site where our users upload files. Django's API uses the 'username.'
When we handle registration we just use email. It seems that Django (or maybe it is AllAuth) just truncates the email to build the username:
email: name@gmail.com --> username: name
This is fine for the most part. And Django may even handle username collisions because because it actually works off of the ID and just displays 'username' for human friendly reasons (IDK).
The issue I foresee is as follows: If we build file paths based on username, e.g. all of user1's files are in files/user1, we have a potential collision because at this point, on say AWS S3 we are no longer using Django's (potential) collision handling.
TL DR: what happens if we have two users, one with username1@gmail.com and the other with username1@yahoo.com AND Django sets username to be a truncated email AND we build file paths off of username?
/r/django
https://redd.it/7emdcg
reddit
username collisions • r/django
We are building a site where our users upload files. Django's API uses the 'username.' When we handle registration we just use email. It seems...
[D] Optimization Algorithms: Math and Code
A colleague of mine had mentioned that they were getting asked quite a few questions about optimization algorithms in their interviews for deep learning positions. I decided to make a quick post about the important ones over at 3dbabove: https://3dbabove.com/2017/11/14/optimizationalgorithms/
/r/MachineLearning
https://redd.it/7ehxky
A colleague of mine had mentioned that they were getting asked quite a few questions about optimization algorithms in their interviews for deep learning positions. I decided to make a quick post about the important ones over at 3dbabove: https://3dbabove.com/2017/11/14/optimizationalgorithms/
/r/MachineLearning
https://redd.it/7ehxky
3dB Above
Optimization Algorithms
An objective function is a measure of how similar a prediction of a value and the actual value are. Usually, we are looking to find the set of parameters that lead to the smallest possible cost whi…
How to create multiple user registration forms with flask-user
Hello
I understand that flask-user allows users with various roles to login. Based on the different roles that are available to users, each user can access routes that are available to that user and role.
However, I am trying to set up multiple registration pages for each user-role.
E.g. users with admin role have one signup page which asks for a lot of information up front , whereas users with regular role will have a simplified signup page just asking for basic details.
How can this be achieved using flask-user.
One good example would be Employers and Candidates on a job portal. How can we have 2 different forms - one for employers to sign up and another one for candidate sign up - for example..
Thanks
/r/flask
https://redd.it/7b5z77
Hello
I understand that flask-user allows users with various roles to login. Based on the different roles that are available to users, each user can access routes that are available to that user and role.
However, I am trying to set up multiple registration pages for each user-role.
E.g. users with admin role have one signup page which asks for a lot of information up front , whereas users with regular role will have a simplified signup page just asking for basic details.
How can this be achieved using flask-user.
One good example would be Employers and Candidates on a job portal. How can we have 2 different forms - one for employers to sign up and another one for candidate sign up - for example..
Thanks
/r/flask
https://redd.it/7b5z77
reddit
How to create multiple user registration forms with... • r/flask
Hello I understand that flask-user allows users with various roles to login. Based on the different roles that are available to users, each...
Open Offer to Mentor
https://www.reddit.com/r/learnpython/comments/7eniv1/open_offer_to_mentor/
/r/djangolearning
https://redd.it/7enj21
https://www.reddit.com/r/learnpython/comments/7eniv1/open_offer_to_mentor/
/r/djangolearning
https://redd.it/7enj21
reddit
Open Offer to Mentor • r/learnpython
Ideally, you already know the basics, but you're struggling (as did I) with going from writing a few loops and a few functions here and there to...
Our Jupyter/IPython client for iPad now includes introductory notebooks on Python, NumPy, Matplotlib and SciPy that you can run without any preliminary configuration. Sign up for beta to run on your iPad!
https://juno.sh/juno-v-1-0-6-beta/
/r/IPython
https://redd.it/7embl0
https://juno.sh/juno-v-1-0-6-beta/
/r/IPython
https://redd.it/7embl0
Juno
Juno v.1.0.7 beta
A new beta release of Juno, Jupyter/IPython client for iPad.
I want to learn Python web development but I'm not sure if I should learn Flask or Django framework.
/r/Python
https://redd.it/7ena2q
/r/Python
https://redd.it/7ena2q
reddit
I want to learn Python web development but I'm not sure... • r/Python
94 points and 33 comments so far on reddit
Integrate bar chart in Flask app with database
I created a Flask app with a flask-sqlalchemy database. I would like one of the pages to show a bar chart which fetches data from said database, but Google hasn't helped much so far. Maybe someone has some hot tip? :)
/r/flask
https://redd.it/7eps8j
I created a Flask app with a flask-sqlalchemy database. I would like one of the pages to show a bar chart which fetches data from said database, but Google hasn't helped much so far. Maybe someone has some hot tip? :)
/r/flask
https://redd.it/7eps8j
reddit
Integrate bar chart in Flask app with database • r/flask
I created a Flask app with a flask-sqlalchemy database. I would like one of the pages to show a bar chart which fetches data from said database,...
What is the design decision for different clients (e.g., jupyter) to share the same ipython kernels?
WHat the problem with it?
/r/IPython
https://redd.it/7ek04k
WHat the problem with it?
/r/IPython
https://redd.it/7ek04k
reddit
What is the design decision for different clients... • r/IPython
WHat the problem with it?
Can a admin inline access the parent attributes?
class ChildInline(admin.TabularInline):
model = # I want this to change depending on the Parent's model selection
class ParentAdmin(admin.ModelAdmin):
inlines = [ChildInline]
/r/django
https://redd.it/7et5eg
class ChildInline(admin.TabularInline):
model = # I want this to change depending on the Parent's model selection
class ParentAdmin(admin.ModelAdmin):
inlines = [ChildInline]
/r/django
https://redd.it/7et5eg
reddit
Can a admin inline access the parent attributes? • r/django
class ChildInline(admin.TabularInline): model = # I want this to change depending on the Parent's model selection class...
How do you concatenate the values of a many-to-many field into a single field in Django?
I have a model that I am querying against, let's call it M. M has a many-to-many relationship with another model, let's call that R. For a queryset of Ms, I want to add an annotation that contains the names of the related Rs as a string of comma separated values. Is there a way to do this in Django?
/r/django
https://redd.it/7ertd9
I have a model that I am querying against, let's call it M. M has a many-to-many relationship with another model, let's call that R. For a queryset of Ms, I want to add an annotation that contains the names of the related Rs as a string of comma separated values. Is there a way to do this in Django?
/r/django
https://redd.it/7ertd9
reddit
How do you concatenate the values of a many-to-many... • r/django
I have a model that I am querying against, let's call it M. M has a many-to-many relationship with another model, let's call that R. For a...
Python overtakes R, becomes the leader in Data Science, Machine Learning platforms
https://www.kdnuggets.com/2017/08/python-overtakes-r-leader-analytics-data-science.html
/r/Python
https://redd.it/7eqieq
https://www.kdnuggets.com/2017/08/python-overtakes-r-leader-analytics-data-science.html
/r/Python
https://redd.it/7eqieq
reddit
Python overtakes R, becomes the leader in Data Science,... • r/Python
267 points and 23 comments so far on reddit
Do you recommend using Digital Ocean 1-Click Django on Ubuntu Image ?
I am getting into deploying a site that uses postgres on a server. I thought Digital Ocean 1-Click Django on Ubuntu Image might be better than doing everything myself form scratch since I don't have the experience.
Most of the tutorials I find start from scratch. I have found that having some things already configured like a postgres user and database, makes me worry that things will break if I for example create a database specific for my project.
Do you think this image will help ease the whole process or it will restrict me ?
/r/django
https://redd.it/7eutn6
I am getting into deploying a site that uses postgres on a server. I thought Digital Ocean 1-Click Django on Ubuntu Image might be better than doing everything myself form scratch since I don't have the experience.
Most of the tutorials I find start from scratch. I have found that having some things already configured like a postgres user and database, makes me worry that things will break if I for example create a database specific for my project.
Do you think this image will help ease the whole process or it will restrict me ?
/r/django
https://redd.it/7eutn6
reddit
Do you recommend using Digital Ocean 1-Click Django on... • r/django
I am getting into deploying a site that uses postgres on a server. I thought Digital Ocean 1-Click Django on Ubuntu Image might be better than...
Live chat on website that has backend of Django
Hey guys.
I have recently started learning django and I am making a website. I wanted to put live chat in the website but I noticed that Django doesn't have that. Is there any way that I can make a live chat on my website with Django or any easy way to do this?
I know that socket.io for node.js is good for live chats, but since I am new to web development I rather stick to one if possible. Also I am not sure how I would deploy a website that has 2 backend programming languages.
Thank you!
/r/django
https://redd.it/7ev08o
Hey guys.
I have recently started learning django and I am making a website. I wanted to put live chat in the website but I noticed that Django doesn't have that. Is there any way that I can make a live chat on my website with Django or any easy way to do this?
I know that socket.io for node.js is good for live chats, but since I am new to web development I rather stick to one if possible. Also I am not sure how I would deploy a website that has 2 backend programming languages.
Thank you!
/r/django
https://redd.it/7ev08o
reddit
Live chat on website that has backend of Django • r/django
Hey guys. I have recently started learning django and I am making a website. I wanted to put live chat in the website but I noticed that Django...
[AF] File to be downloaded doesn't update / firefox caching problem
Sorry for the vague title. The situation is as follows: I have a download link on a page, and after clicking on the download link, the user is sent a .csv file. The user then edits some information on the site, which should appear on the .csv file. After editing, the user returns to the downloads page and downloads the same file again. However, the updates are not visible and the old file is being downloaded.
After deleting the firefox cache or opening site in private window, the new file is presented. The problem does not exist in chrome.
Is there some way to disable this behavior?
/r/flask
https://redd.it/7erw9a
Sorry for the vague title. The situation is as follows: I have a download link on a page, and after clicking on the download link, the user is sent a .csv file. The user then edits some information on the site, which should appear on the .csv file. After editing, the user returns to the downloads page and downloads the same file again. However, the updates are not visible and the old file is being downloaded.
After deleting the firefox cache or opening site in private window, the new file is presented. The problem does not exist in chrome.
Is there some way to disable this behavior?
/r/flask
https://redd.it/7erw9a
reddit
[AF] File to be downloaded doesn't update / firefox... • r/flask
Sorry for the vague title. The situation is as follows: I have a download link on a page, and after clicking on the download link, the user is...
Adding Jekyll to create documentation page onto Flask web application?
Hello, I was wondering if anyone had experience using Jekyll in order to create a nice documentation page, and adding it onto a Flask web application.
I've already create the bulk of the web application with Flask. I was hoping to create an @app.route('/documentation', methods=['GET]) which would direct users to a documentation page, which would be made with Jekyll. I'm new to this and a bit confused about where to start. Any resources or help would be greatly appreciated. Thank you!
/r/flask
https://redd.it/7ewpla
Hello, I was wondering if anyone had experience using Jekyll in order to create a nice documentation page, and adding it onto a Flask web application.
I've already create the bulk of the web application with Flask. I was hoping to create an @app.route('/documentation', methods=['GET]) which would direct users to a documentation page, which would be made with Jekyll. I'm new to this and a bit confused about where to start. Any resources or help would be greatly appreciated. Thank you!
/r/flask
https://redd.it/7ewpla
reddit
Adding Jekyll to create documentation page onto Flask... • r/flask
Hello, I was wondering if anyone had experience using Jekyll in order to create a nice documentation page, and adding it onto a Flask web...
Projects for a beginner?
Which projects should a beginner at Python start at, and then progress too? I don't have anything in mind right now, so I don't have a lot of ideas.
/r/Python
https://redd.it/7exjil
Which projects should a beginner at Python start at, and then progress too? I don't have anything in mind right now, so I don't have a lot of ideas.
/r/Python
https://redd.it/7exjil
reddit
Projects for a beginner? • r/Python
Which projects should a beginner at Python start at, and then progress too? I don't have anything in mind right now, so I don't have a lot of ideas.
Help serving static file sitemap.xml
Hello,
I am having issues serving my sitemap.xml file. It works on localhost:5000/sitemap.xml but not on the live domain. I am hosting this on a Linux server with Apache2
This is what I get on the live domain:
"Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and
try again."
This is my code:
import _mysql
from flask import Flask, request, jsonify, redirect,
url_for,render_template, send_from_directory,session,
abort,json,flash
import os
import prettyprint
import sys
reload(sys)
sys.setdefaultencoding('utf8')
PATH = os.path.dirname(os.path.abspath(__file__))
app=Flask("Locals",template_folder=os.path.join(PATH,
'templates'),static_folder='static')
@app.route('/sitemap.xml')
def static_from_root():
return send_from_directory(app.static_folder, request.path[1:])
@app.route("/", defaults={'state': None, 'city': None, 'keyword':
None})
@app.route("/<state>", defaults={'city': None, 'keyword': None})
@app.route("/<state>/<city>", defaults={'keyword': None})
@app.route("/<state>/<city>/<keyword>")
def index(state,city,keyword):
& at the bottom:
if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0', port=5000)
/r/flask
https://redd.it/7erilu
Hello,
I am having issues serving my sitemap.xml file. It works on localhost:5000/sitemap.xml but not on the live domain. I am hosting this on a Linux server with Apache2
This is what I get on the live domain:
"Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and
try again."
This is my code:
import _mysql
from flask import Flask, request, jsonify, redirect,
url_for,render_template, send_from_directory,session,
abort,json,flash
import os
import prettyprint
import sys
reload(sys)
sys.setdefaultencoding('utf8')
PATH = os.path.dirname(os.path.abspath(__file__))
app=Flask("Locals",template_folder=os.path.join(PATH,
'templates'),static_folder='static')
@app.route('/sitemap.xml')
def static_from_root():
return send_from_directory(app.static_folder, request.path[1:])
@app.route("/", defaults={'state': None, 'city': None, 'keyword':
None})
@app.route("/<state>", defaults={'city': None, 'keyword': None})
@app.route("/<state>/<city>", defaults={'keyword': None})
@app.route("/<state>/<city>/<keyword>")
def index(state,city,keyword):
& at the bottom:
if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0', port=5000)
/r/flask
https://redd.it/7erilu
reddit
Help serving static file sitemap.xml • r/flask
Hello, I am having issues serving my sitemap.xml file. It works on localhost:5000/sitemap.xml but not on the live domain. I am hosting this on a...