How to deploy a multi-tenant django app to AWS?
I have an Django+Postgres app that has a multi-tenant structure and I don't have prior experience deploying this type of app to AWS. I have followed the general Elastic Beanstalk tutorial to deploy a simple app. (https://realpython.com/blog/python/deploying-a-django-app-to-aws-elastic-beanstalk/) However, I am looking for a solution that allows me to more flexibly create different "sites". Currently, I have learned to create different sites via this tutorial (http://mycodesmells.com/post/django-tutorial-multi-tenant-setup). And I don't have a good idea as of 1. how to deploy this app 2. how I could create different sites after deploying this app.
/r/django
https://redd.it/5lcmtf
I have an Django+Postgres app that has a multi-tenant structure and I don't have prior experience deploying this type of app to AWS. I have followed the general Elastic Beanstalk tutorial to deploy a simple app. (https://realpython.com/blog/python/deploying-a-django-app-to-aws-elastic-beanstalk/) However, I am looking for a solution that allows me to more flexibly create different "sites". Currently, I have learned to create different sites via this tutorial (http://mycodesmells.com/post/django-tutorial-multi-tenant-setup). And I don't have a good idea as of 1. how to deploy this app 2. how I could create different sites after deploying this app.
/r/django
https://redd.it/5lcmtf
Realpython
Deploying a Django App to AWS Elastic Beanstalk – Real Python
Let's look at how to deploy a Django App to AWS Elastic Beanstalk.
Does anyone use Tkinter anymore?
For an upcoming GUI based app, I'm considering between CSharp and Python. Now, since a lot of my backend libraries used for that app are in Python, I'm going to need Python anyways. However, I'm not familiar with any GUI library in Python, though I've heard a bit about Tkinter.
However, the last I heard about that, it seemed to have gathered rust and not being used as much as wxwidgets and others (even Guide Van Rossum seemed to be favoring wxwidgets).
For basic GUI stuff (lists, dropdowns, buttons and maybe a few charts), what library do you suggest?
/r/Python
https://redd.it/5laauy
For an upcoming GUI based app, I'm considering between CSharp and Python. Now, since a lot of my backend libraries used for that app are in Python, I'm going to need Python anyways. However, I'm not familiar with any GUI library in Python, though I've heard a bit about Tkinter.
However, the last I heard about that, it seemed to have gathered rust and not being used as much as wxwidgets and others (even Guide Van Rossum seemed to be favoring wxwidgets).
For basic GUI stuff (lists, dropdowns, buttons and maybe a few charts), what library do you suggest?
/r/Python
https://redd.it/5laauy
reddit
Does anyone use Tkinter anymore? • /r/Python
For an upcoming GUI based app, I'm considering between CSharp and Python. Now, since a lot of my backend libraries used for that app are in...
Help with Flask-login and sqlite3
Hi all,
I'm trying to build a site that has users log in using an sqlite3 database. I've come across flask-login as what I should be using for this. I think I am close to getting it up and running but it seems that when I run the login page, it runs the load_user function twice and the second time load_user is called it returns an empty list which predictably causes some problems (this shows up in the "print result" line in the load_user). ~~I have no idea why the load_user is being called twice~~. It is being called once on the GET and again on the POST, I still don't know why this is happening. I tried debugging it but I've had no luck. I've been trying so many different things that if it is easier just to point me towards a tutorial on how this works, I would appreciate that as well (one that covers databases). I've read the official docs and they were not clear enough for me unfortunately. Here is the code I am using
from flask import Flask, Response, request, redirect, abort, url_for, flash
from flask_login import LoginManager, UserMixin, login_required, login_user, logout_user, current_user
from database import database
app = Flask(__name__)
# config
app.config.update(
DEBUG=True,
SECRET_KEY='secret_xxx'
)
# _________________________________________________________________________________________________________________
# flask-login
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "/login"
class User(UserMixin):
def __init__(self, id, name, password):
self.id = unicode(id)
self.name = name
self.password = password
self.authenticated = False
def is_active(self):
# code to check if user is active
return self.is_active()
def is_anonymous(self):
return False
def is_authenticated(self):
return self.authenticated
def is_active(self):
return True
def get_id(self):
return self.id
# __________________________________________________________________________________________________________________
@app.route('/', methods=['GET', 'POST'])
def index():
# Here we use a class of some kind to represent and validate our
return Response ("hello world everyone!")
# some protected url
@app.route('/protected')
@login_required
def protected():
return Response("""
<p>Hello protected!</p>
""")
def sign_in_user(username, password):
user = load_user(username)
if user and user.password == password:
user.authenticated = True
login_user(user)
return user
@app.route("/login", methods=["GET", "POST"], endpoint='login')
def login():
if request.method == 'POST':
username = request.form['username']
password = request.form['password']
user = sign_in_user(username, password)
if user.is_authenticated:
return redirect('protected')
else:
return redirect('login')
else:
return Response('''
<form action="" method="post">
<p><input type=text name=username>
<p><input type=password name=password>
<p><input type=submit value=Login>
</form>
''')
@login_manager.user_loader
def load_user(username):
print "load user called"
mydatabase = database()
result = mydatabase.queryUser(username)
print result
if result == None:
return None
else:
user = User(result[0], result[1], result[2])
return user
if __name__ == "__main__":
app.run()
/r/flask
https://redd.it/5ldblw
Hi all,
I'm trying to build a site that has users log in using an sqlite3 database. I've come across flask-login as what I should be using for this. I think I am close to getting it up and running but it seems that when I run the login page, it runs the load_user function twice and the second time load_user is called it returns an empty list which predictably causes some problems (this shows up in the "print result" line in the load_user). ~~I have no idea why the load_user is being called twice~~. It is being called once on the GET and again on the POST, I still don't know why this is happening. I tried debugging it but I've had no luck. I've been trying so many different things that if it is easier just to point me towards a tutorial on how this works, I would appreciate that as well (one that covers databases). I've read the official docs and they were not clear enough for me unfortunately. Here is the code I am using
from flask import Flask, Response, request, redirect, abort, url_for, flash
from flask_login import LoginManager, UserMixin, login_required, login_user, logout_user, current_user
from database import database
app = Flask(__name__)
# config
app.config.update(
DEBUG=True,
SECRET_KEY='secret_xxx'
)
# _________________________________________________________________________________________________________________
# flask-login
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "/login"
class User(UserMixin):
def __init__(self, id, name, password):
self.id = unicode(id)
self.name = name
self.password = password
self.authenticated = False
def is_active(self):
# code to check if user is active
return self.is_active()
def is_anonymous(self):
return False
def is_authenticated(self):
return self.authenticated
def is_active(self):
return True
def get_id(self):
return self.id
# __________________________________________________________________________________________________________________
@app.route('/', methods=['GET', 'POST'])
def index():
# Here we use a class of some kind to represent and validate our
return Response ("hello world everyone!")
# some protected url
@app.route('/protected')
@login_required
def protected():
return Response("""
<p>Hello protected!</p>
""")
def sign_in_user(username, password):
user = load_user(username)
if user and user.password == password:
user.authenticated = True
login_user(user)
return user
@app.route("/login", methods=["GET", "POST"], endpoint='login')
def login():
if request.method == 'POST':
username = request.form['username']
password = request.form['password']
user = sign_in_user(username, password)
if user.is_authenticated:
return redirect('protected')
else:
return redirect('login')
else:
return Response('''
<form action="" method="post">
<p><input type=text name=username>
<p><input type=password name=password>
<p><input type=submit value=Login>
</form>
''')
@login_manager.user_loader
def load_user(username):
print "load user called"
mydatabase = database()
result = mydatabase.queryUser(username)
print result
if result == None:
return None
else:
user = User(result[0], result[1], result[2])
return user
if __name__ == "__main__":
app.run()
/r/flask
https://redd.it/5ldblw
reddit
Help with Flask-login and sqlite3 • /r/flask
Hi all, I'm trying to build a site that has users log in using an sqlite3 database. I've come across flask-login as what I should be using for...
Calling Python from React in an Electron App
https://gitlab.com/avilay/electron-react-python-app
/r/Python
https://redd.it/5lefaz
https://gitlab.com/avilay/electron-react-python-app
/r/Python
https://redd.it/5lefaz
GitLab
avilay / electron-react-python-app
Global redirect if a certain criteria isn't set
What would be the best way to redirect a user globally (to a view for example) if that user doesn't fall into a group for example? I cannot for the life of me figure out an elegant way to get this accomplished
/r/django
https://redd.it/5ler7x
What would be the best way to redirect a user globally (to a view for example) if that user doesn't fall into a group for example? I cannot for the life of me figure out an elegant way to get this accomplished
/r/django
https://redd.it/5ler7x
reddit
Global redirect if a certain criteria isn't set • /r/django
What would be the best way to redirect a user globally (to a view for example) if that user doesn't fall into a group for example? I cannot for...
What's really up with apps?
Hi /r/django!
So - I have really tried to read and understand this, but I just can't seem to grasp it :-( Maybe someone here could give me an explanation that I can understand xD
When do I choose to split a single project into multiple apps? As an example, right now I'm planning an accounting project that looks like "mint.com". It should contain a part for adding, viewing, categorizeing etc transactions, and one part to create and manage budgets. should these two parts be two apps? Why / Why not? This project also uses the same design layout, both for the transaction logging and the budgets. How is this handled if multiple apps are using the same static files and blocks?
Thanks for help in advance! :-D
/r/django
https://redd.it/5lf31s
Hi /r/django!
So - I have really tried to read and understand this, but I just can't seem to grasp it :-( Maybe someone here could give me an explanation that I can understand xD
When do I choose to split a single project into multiple apps? As an example, right now I'm planning an accounting project that looks like "mint.com". It should contain a part for adding, viewing, categorizeing etc transactions, and one part to create and manage budgets. should these two parts be two apps? Why / Why not? This project also uses the same design layout, both for the transaction logging and the budgets. How is this handled if multiple apps are using the same static files and blocks?
Thanks for help in advance! :-D
/r/django
https://redd.it/5lf31s
reddit
What's really up with apps? • /r/django
Hi /r/django! So - I have really tried to read and understand this, but I just can't seem to grasp it :-( Maybe someone here could give me an...
Can python pickle files act as a small database system backend?
I'm writing a small app in python and usually I use sqlite as the backend for this sort of thing. However, I'm thinking that rather than iterating through a python list or dict and writing each record to sqlite cursor, why not just pickle the entire object and take it from then on? How feasible is this thing, have you ever tried it?
/r/Python
https://redd.it/5lf5ur
I'm writing a small app in python and usually I use sqlite as the backend for this sort of thing. However, I'm thinking that rather than iterating through a python list or dict and writing each record to sqlite cursor, why not just pickle the entire object and take it from then on? How feasible is this thing, have you ever tried it?
/r/Python
https://redd.it/5lf5ur
reddit
Can python pickle files act as a small database system... • /r/Python
I'm writing a small app in python and usually I use sqlite as the backend for this sort of thing. However, I'm thinking that rather than iterating...
Deploy Flask-Ask to AWS Lambda using Zappa
https://www.youtube.com/watch?v=mjWV4R2P4ks
/r/flask
https://redd.it/5l6ycj
https://www.youtube.com/watch?v=mjWV4R2P4ks
/r/flask
https://redd.it/5l6ycj
YouTube
Deploy Flask-Ask to AWS Lambda with Zappa
Peewee does not initialize database tables
I'm trying to create a blueprint based wiki. It's based on [these](https://gist.github.com/coleifer/5449d29f25e0d78bc2e8) code snippets. I'm using peewee as ORM and the playhouse.flask_utils package so I can use init_app in the application factory.
The database is created but it's empty.
https://gist.github.com/yhamdoud/dbd9d50e0863eaf6f4b36504dce98582
/r/flask
https://redd.it/5lgbwd
I'm trying to create a blueprint based wiki. It's based on [these](https://gist.github.com/coleifer/5449d29f25e0d78bc2e8) code snippets. I'm using peewee as ORM and the playhouse.flask_utils package so I can use init_app in the application factory.
The database is created but it's empty.
https://gist.github.com/yhamdoud/dbd9d50e0863eaf6f4b36504dce98582
/r/flask
https://redd.it/5lgbwd
Gist
Wiki
I created a bot that analyzes a user's comments and determines if they are positive or negative.
Just mention my username in a comment along with the username of the person you would like to analyze and /u/opfeels will respond with the analyzation results.
I use the Python Reddit API Wrapper to extract the most recent 100 comments from a user. I take those comments and extract sentences that aren't too long and aren't too short. Each sentence is then analyzed using the NLTK Sentiment Analyzer Vader Module and scored based on how positive, negative, and neutral it is. I then rank the analyzed users in order from most positive to least positive.
you can also use the website: [ruadick.com](http://ruadick.com)
EDIT: fixed bug "<bound method Redditor.index of <Redditor: Redditor object>>" remember the () when calling functions. =)
/r/Python
https://redd.it/5lgot5
Just mention my username in a comment along with the username of the person you would like to analyze and /u/opfeels will respond with the analyzation results.
I use the Python Reddit API Wrapper to extract the most recent 100 comments from a user. I take those comments and extract sentences that aren't too long and aren't too short. Each sentence is then analyzed using the NLTK Sentiment Analyzer Vader Module and scored based on how positive, negative, and neutral it is. I then rank the analyzed users in order from most positive to least positive.
you can also use the website: [ruadick.com](http://ruadick.com)
EDIT: fixed bug "<bound method Redditor.index of <Redditor: Redditor object>>" remember the () when calling functions. =)
/r/Python
https://redd.it/5lgot5
Ruadick
Commenter Sentiment Analysis
Comments from the top subreddets have been analyzed using the NLTK Sentiment Analyzer Vader Module and scored based on how positive, negative, and neutral it is.
2 Scoops of Django
I've seen 2 Scoops of Django recommended a few times, but the most recent version is for Django 1.8. If I'm totally new to Django, will this mess me up?
/r/django
https://redd.it/5lf9sb
I've seen 2 Scoops of Django recommended a few times, but the most recent version is for Django 1.8. If I'm totally new to Django, will this mess me up?
/r/django
https://redd.it/5lf9sb
reddit
2 Scoops of Django • /r/django
I've seen 2 Scoops of Django recommended a few times, but the most recent version is for Django 1.8. If I'm totally new to Django, will this mess...
Admin page suddenly gone!
Hi again /r/django!
So - I was coding my project and created some models. These models were registered to admin page and all worked as expected. I continued and added some html templates to a different app, and suddenly my admin-page is empty. the header text is gone and the only thing i can see when I go to localhost:8000/admin/ is "Site administration". That's it. The "Authentication and authorization" part is gone, and my other app is gone. However! If I now go to localhost:8000/admin/<myapp>/, the stuff for the app is shown. What have I done wrong? It happened after I added a "global" template folder in the project root, and added the path to this template folder in the TEMPLATES dict.
/r/django
https://redd.it/5lggur
Hi again /r/django!
So - I was coding my project and created some models. These models were registered to admin page and all worked as expected. I continued and added some html templates to a different app, and suddenly my admin-page is empty. the header text is gone and the only thing i can see when I go to localhost:8000/admin/ is "Site administration". That's it. The "Authentication and authorization" part is gone, and my other app is gone. However! If I now go to localhost:8000/admin/<myapp>/, the stuff for the app is shown. What have I done wrong? It happened after I added a "global" template folder in the project root, and added the path to this template folder in the TEMPLATES dict.
/r/django
https://redd.it/5lggur
reddit
Admin page suddenly gone! • /r/django
Hi again /r/django! So - I was coding my project and created some models. These models were registered to admin page and all worked as expected....
Amazon Alert: Track prices on Amazon and receive email alerts for price drops! (Fun Weekend Project)
https://github.com/anfederico/Amazon-Alert
/r/Python
https://redd.it/5lhwb6
https://github.com/anfederico/Amazon-Alert
/r/Python
https://redd.it/5lhwb6
GitHub
anfederico/Amazon-Alert
Track prices on Amazon and receive email alerts for price drops - anfederico/Amazon-Alert
yarl - URL manipulation library, with nice pythonic API, inspired by pathlib
https://github.com/aio-libs/yarl
/r/Python
https://redd.it/5lh367
https://github.com/aio-libs/yarl
/r/Python
https://redd.it/5lh367
GitHub
GitHub - aio-libs/yarl: Yet another URL library
Yet another URL library. Contribute to aio-libs/yarl development by creating an account on GitHub.
Need a new year's resolution? Try 'The Ultimate Reading List for Developers' post I wrote a couple of months back
https://medium.com/@YogevSitton/the-ultimate-reading-list-for-developers-e96c832d9687#.9m6quqo5j
/r/flask
https://redd.it/5lgt6r
https://medium.com/@YogevSitton/the-ultimate-reading-list-for-developers-e96c832d9687#.9m6quqo5j
/r/flask
https://redd.it/5lgt6r
Medium
The Ultimate Reading List for Developers
I’ve been a software developer for some time now. I started with web development in 2004, moved to a full stack position in 2009 and began…
[D] [Humour] Some new year burn for the community
https://twitter.com/fchollet/status/815653113113743360
/r/MachineLearning
https://redd.it/5li64n
https://twitter.com/fchollet/status/815653113113743360
/r/MachineLearning
https://redd.it/5li64n
Twitter
François Chollet
How I get my ML news: 1) Twitter 2) arxiv 3) mailing lists . . . 97) overheard at ramen place 98) graffiti in bathroom stall 99) /r/ml
Blog tutorial in Django 1.10
Hello friends! Happy New Year!
I am new to Django and I am seeking your support. I'm trying to build a pretty complex website with a blog section. I've tried numerous tutorials on YouTube and the documentation and I've ended up frustrated because either the tutorial doesn't really cover everything or I'm running into compatibility issues (Django 1.9 vs Django 1.10) which I couldn't figure out. These two do not really cut it:
https://www.youtube.com/watch?v=FNQxxpM1yOs&list=PLQVvvaa0QuDeA05ZouE4OzDYLHY-XH-Nd
https://www.youtube.com/watch?v=yfgsklK_yFo&list=PLEsfXFp6DpzQFqfCur9CJ4QnKQTVXUsRy
Could someone please point me to a full in depth Django 1.10 tutorial or some kind of template? I've pretty good at the Front End and I just want to get my first webapp off the ground.
Much appreciated
/r/django
https://redd.it/5lk67y
Hello friends! Happy New Year!
I am new to Django and I am seeking your support. I'm trying to build a pretty complex website with a blog section. I've tried numerous tutorials on YouTube and the documentation and I've ended up frustrated because either the tutorial doesn't really cover everything or I'm running into compatibility issues (Django 1.9 vs Django 1.10) which I couldn't figure out. These two do not really cut it:
https://www.youtube.com/watch?v=FNQxxpM1yOs&list=PLQVvvaa0QuDeA05ZouE4OzDYLHY-XH-Nd
https://www.youtube.com/watch?v=yfgsklK_yFo&list=PLEsfXFp6DpzQFqfCur9CJ4QnKQTVXUsRy
Could someone please point me to a full in depth Django 1.10 tutorial or some kind of template? I've pretty good at the Front End and I just want to get my first webapp off the ground.
Much appreciated
/r/django
https://redd.it/5lk67y
YouTube
Introduction - Django Web Development with Python 1
Welcome to a Django web development with Python tutorial series. Django is a Python web development framework, aimed at rapid development and deployment.
One of the more common questions people have is "which framework" they should use. There are quite a…
One of the more common questions people have is "which framework" they should use. There are quite a…
URL not appearing in DRF router!
I have all these router url's set up, but when I add search it doesn't work!
router.register(r'search', search_api.SearchViewSet, base_name='search-api')
i've narrowed it down to when i swap out where the view goes (search_api.SearchViewSet), then it shows up on the django 404 page.... I've tried many combinations of views and nothing makes it work! Why could this be. For example, my current view is :
class SearchViewSet(viewsets.ViewSet):
queryset = Data.objects.all()
renderer_classes = (JSONRenderer, )
def get(self, request, format=None):
print('test')
return Response({'test': 1})
/r/django
https://redd.it/5knjfe
I have all these router url's set up, but when I add search it doesn't work!
router.register(r'search', search_api.SearchViewSet, base_name='search-api')
i've narrowed it down to when i swap out where the view goes (search_api.SearchViewSet), then it shows up on the django 404 page.... I've tried many combinations of views and nothing makes it work! Why could this be. For example, my current view is :
class SearchViewSet(viewsets.ViewSet):
queryset = Data.objects.all()
renderer_classes = (JSONRenderer, )
def get(self, request, format=None):
print('test')
return Response({'test': 1})
/r/django
https://redd.it/5knjfe
reddit
URL not appearing in DRF router! • /r/django
I have all these router url's set up, but when I add search it doesn't work! router.register(r'search', search_api.SearchViewSet,...
Django or flask?
I am completely inexperienced these libraries. I wanted to see it it'd be feasible to build a site that would display some matplotlib graphs and pandas dataframes. Ideally, these dataframes could be filtered or sorted and exported. The underlying raw data would be refreshed every 30 minutes. Someone could visit and see overall performance and then customize their view.
Another big use case for me would be to allow people to update some "custom" dimension tables and to let me know when certain dimensions are expired or recycled. Right now this is done through csv files being overwritten on an sftp site. It'd be nice to have a front end.
My workflow is centered around using a few libraries to gather external data from SFTP sites, shared folders, and even web sites with selenium. I then read this data with pandas, do my formatting and cleaning, etc, and then I use psycopg2 COPY command to send the data to Postgres. Ultimately, his external data (all different formats and sources) comes together into internal reports.
Some of the data is used for reporting which is sent out through emails (attachments and to_html with pandas to display a table), tableau, and to various shared folders and sftp sites. I'd like to test having some of this on a website instead.
/r/Python
https://redd.it/5lk0or
I am completely inexperienced these libraries. I wanted to see it it'd be feasible to build a site that would display some matplotlib graphs and pandas dataframes. Ideally, these dataframes could be filtered or sorted and exported. The underlying raw data would be refreshed every 30 minutes. Someone could visit and see overall performance and then customize their view.
Another big use case for me would be to allow people to update some "custom" dimension tables and to let me know when certain dimensions are expired or recycled. Right now this is done through csv files being overwritten on an sftp site. It'd be nice to have a front end.
My workflow is centered around using a few libraries to gather external data from SFTP sites, shared folders, and even web sites with selenium. I then read this data with pandas, do my formatting and cleaning, etc, and then I use psycopg2 COPY command to send the data to Postgres. Ultimately, his external data (all different formats and sources) comes together into internal reports.
Some of the data is used for reporting which is sent out through emails (attachments and to_html with pandas to display a table), tableau, and to various shared folders and sftp sites. I'd like to test having some of this on a website instead.
/r/Python
https://redd.it/5lk0or
reddit
Django or flask? • /r/Python
I am completely inexperienced these libraries. I wanted to see it it'd be feasible to build a site that would display some matplotlib graphs and...
How to Activate/Deactivate virtualenv on linux with subprocess.Popen?
I achieved to create and to activate the virtualenv on Linux but I cannot deactivate it.
The deactivate command is not available through subprocess.Popen even if shell argument is set to True.
Do you have any ideas?
/r/Python
https://redd.it/5lift9
I achieved to create and to activate the virtualenv on Linux but I cannot deactivate it.
The deactivate command is not available through subprocess.Popen even if shell argument is set to True.
Do you have any ideas?
/r/Python
https://redd.it/5lift9
reddit
How to Activate/Deactivate virtualenv on linux with... • /r/Python
I achieved to create and to activate the virtualenv on Linux but I cannot deactivate it. The deactivate command is not available through...