You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
<p>You're knee deep in learning the <ahref="http://www.python.org/">Python</a>
programming language. The syntax is starting to make sense. The first
few "<em>ahh-ha</em>!" moments are hitting you as you're learning conditional
statements, for loops and classes while playing around with the open source
libraries that make Python such an amazing language.</p>
<p>Now you want to take your initial Python knowledge and make something real.
A real web application that's available on the web which you can show off or
sell as a service to other people. That's where Full Stack Python comes in.
You've come to the right place to learn everything you need to deploy and
run a production Python web application.</p>
<p>This guide branches out on topic because your learning needs depend on what
you're currently trying to do. </p>
<h3>Let's get started. What do you need to do right now?</h3>
<h1>Web frameworks</h1>
<p>A web framework is a code library that makes a developer's life easier when
building reliable, scalable and maintainable web applications.</p>
<h2>Why are web frameworks necessary?</h2>
<p>Web frameworks encapsulate what developers have learned over the past twenty
years while programming sites and applications for the web. Frameworks make
it easier to reuse code for common HTTP operations and to structure projects
so developers with knowledge of the framework can more quickly build and
maintain the application.</p>
<h2>Common web framework functionality</h2>
<p>Frameworks provide functionality in their code or through extensions to
perform common operations required to run web applications. These common
operations include:</p>
<ol>
<li>URL routing</li>
<li>HTML, XML, JSON, and other output format templating</li>
<li>Database manipulation</li>
<li>Security against Cross-site request forgery (CSRF) and other attacks</li>
</ol>
<p>Not all web frameworks include code for all of the above
functionality. Frameworks fall somewhere between simply executing a
single use case and attempting to be everything to every developer with
increased complexity. Some frameworks take the "batteries-included" approach
where everything possible comes bundled with the framework while others
have a minimal code library that plays well with extensions.</p>
<p>For example, the Django web application framework includes an
Object-Relational Mapping (ORM) layer that abstracts relational database
read, write, query, and delete operations. However, Django's ORM
cannot work without significant modification on non-relational databases such as
<ahref="http://www.mongodb.org/">MongoDB</a>.
Some other web frameworks such as Flask and Pyramid are easier to
use with non-relational databases by incorporating external Python libraries.
There is a spectrum between minimal functionality with easy extensibility and
including everything in the framework with tight integration.</p>
<h2>General web framework resources</h2>
<ul>
<li>
<p>"<ahref="http://www.jeffknupp.com/blog/2014/03/03/what-is-a-web-framework/">What is a web framework?</a>"
by <ahref="https://twitter.com/jeffknupp">Jeff Knupp</a>
is an in-depth explanation of what web frameworks are and their relation
to web servers.</p>
</li>
<li>
<p>Check out the answer to the
"<ahref="http://stackoverflow.com/questions/4507506/what-is-a-web-framework-how-does-it-compare-with-lamp">What is a web framework and how does it compare to LAMP?</a>"
question on Stack Overflow.</p>
</li>
<li>
<p><ahref="http://youtu.be/W6KCPXl6Zuc">Frameworks</a> is a really well done short video
that explains how to choose between web frameworks. The author has some
particular opinions about what should be in a framework. For the most part
I agree although I've found sessions and database ORMs to be a helpful
part of a framework when done well.</p>
</li>
<li>
<p><ahref="https://www.airpair.com/python/posts/django-flask-pyramid">Django vs Flask vs Pyramid: Choosing a Python Web Framework</a>
contains background information and code comparisons for similar
web applications built in these three big Python frameworks.</p>
</li>
<li>
<p>This <ahref="http://www.konstruktor.ee/blog/python-web-framework-roundup/">Python web framework roundup</a>
covers Django, Flask and Bottle as well as several other lesser known Python
frameworks.</p>
</li>
<li>
<p>This fascinating blog post takes a look at the
<ahref="http://grokcode.com/864/snakefooding-python-code-for-complexity-visualization/">code complexity of several Python web frameworks</a>
by providing visualizations based on their code bases.</p>
</li>
<li>
<p><ahref="http://www.reddit.com/r/webdev/comments/2les4x/what_frameworks_do_you_use_and_why_are_they/">What web frameworks do you use and why are they awesome?</a>
is a language agnostic Reddit discussion on web frameworks. It's interesting
to see what programmers in other languages like and dislike about their
suite of web frameworks compared to the main Python frameworks.</p>
</li>
</ul>
<h2>Web frameworks learning checklist</h2>
<p><iclass="fa fa-check-square-o"></i>
Choose a major Python web framework (<ahref="/django.html">Django</a> or
<ahref="/flask.html">Flask</a> are recommended) and stick with it. When you're just
starting it's best to learn one framework first instead of bouncing around
trying to understand every framework. </p>
<p><iclass="fa fa-check-square-o"></i>
Work through a detailed tutorial found within the resources links on the
framework's page.</p>
<p><iclass="fa fa-check-square-o"></i>
Study open source examples built with your framework of choice so you can
take parts of those projects and reuse the code in your application.</p>
<p><iclass="fa fa-check-square-o"></i>
Build the first simple iteration of your web application then go to
the <ahref="/deployment.html">deployment</a> section to make it accessible on the
web.</p>
<h3>Which web framework do you want to learn about?</h3>
<h1>Django</h1>
<p><ahref="http://www.djangoproject.com/">Django</a> is a widely used Python web
application framework with a "batteries-included" philosophy. The principle
behind batteries-included is that the common functionality for building
web applications should come with the framework instead of as separate
has several nice examples for breaking Django into smaller simplier
components.</p>
</li>
<li>
<p>The <ahref="https://github.com/rogueleaderr/definitive_guide_to_django_deployment">Definitive Guide to Django Deployment</a>
explains the architecture of the resulting set up and includes Chef scripts
to automate the deployment.</p>
</li>
<li>
<p><ahref="http://agiliq.com/blog/2014/08/deploying-a-django-app-on-amazon-ec2-instance/">Deploying a Django app on Amazon EC2 instance</a>
is a detailed walkthrough for deploying an example Django app to Amazon
Web Services.</p>
</li>
<li>
<p>This <ahref="http://aliteralmind.wordpress.com/2014/09/21/jquery_django_tutorial/">step-by-step guide for Django</a>
shows how to transmit data via AJAX with JQuery.</p>
</li>
<li>
<p><ahref="http://www.nickpolet.com/blog/deploying-django-on-aws/1/">Deploying Django on AWS</a>
is another walkthrough for deploying Django to AWS.</p>
</li>
<li>
<p><ahref="https://github.com/rosarior/awesome-django">django-awesome</a> is a curated
list of Django libraries and resources.</p>
</li>
<li>
<p><ahref="https://realpython.com/learn/start-django/">Starting a Django Project</a> answers the question, “How do I set up a Django (1.5, 1.6, or /1.7) project from scratch?”</p>
<p><ahref="https://lincolnloop.com/blog/integrating-front-end-tools-your-django-project/">Integerating Front End Tools with Django</a>
is a good post to read for figuring out how to use <ahref="http://gulpjs.com/">Gulp</a>
for handling front end tools in development and production Django sites.</p>
</li>
</ul>
<h2>Django with Angular (Djangular) resources</h2>
<ul>
<li>
<p><ahref="http://blog.kevinastone.com/getting-started-with-django-rest-framework-and-angularjs.html">Getting Started with Django Rest Framework and AngularJS</a>
is a very detailed introduction to Djangular with example code. </p>
</li>
<li>
<p><ahref="https://thinkster.io/brewer/angular-django-tutorial/">Building Web Applications with Django and AngularJS</a>
is a very detailed guide for using Django as an API layer and AngularJS
as the MVC front end in the browser.</p>
</li>
<li>
<p>This <ahref="http://blog.mourafiq.com/post/55034504632/end-to-end-web-app-with-django-rest-framework">end to end web app with Django-Rest-Framework & AngularJS part 1</a>
is a powerful Django ORM database query inspection tool. Highly recommended
during development to ensure you're writing reasonable query code.
<ahref="http://mtford.co.uk/blog/2/">Django Silk</a> is another inspection tool and
has capabilities to do more than just SQL inspection.</p>
</li>
<li>
<p><ahref="http://reinout.vanrees.org/weblog/2014/05/06/making-faster.html">Making a specific Django app faster</a>
is a Django performance blog post with some tips on measuring performance
and optimizing based on the measured results.</p>
</li>
<li>
<p><ahref="https://speakerdeck.com/alex/why-i-hate-the-django-orm">Why I Hate the Django ORM</a>
is Alex Gaynor's overview of the bad designs decisions, some of which he
made, while building the Django ORM.</p>
</li>
<li>
<p><ahref="https://speakerdeck.com/craigkerstiens/going-beyond-django-orm-with-postgres">Going Beyond Django ORM with Postgres</a>
is specific to using PostgreSQL with Django.</p>
</li>
<li>
<p><ahref="http://www.calazan.com/migrating-django-app-from-mysql-to-postgresql/">Migrating a Django app from MySQL to PostgreSQL</a>
is a quick look at how to move from MySQL to PostgreSQL. However, my guess
is that any Django app that's been running for awhile on one relational
database will require a lot more work to port over to another backend
even with the power of the ORM.</p>
</li>
<li>
<p><ahref="http://blog.kevinastone.com/django-model-descriptors.html">Django Model Descriptors</a>
discusses and shows how to incorporate business logic into Django models
to reduce complexity from the views and make the code easier to reuse across
separate views.</p>
</li>
</ul>
<h2>Static and media files</h2>
<p>Deploying and handling static and media files can be confusing for new
Django developers. These resources along with the
<ahref="/static-content.html">static content</a> page are useful for figuring out how
to handle these files properly.</p>
<ul>
<li>
<p><ahref="http://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/">Using Amazon S3 to Store your Django Site's Static and Media Files</a>
is a well written guide to a question commonly asked about static and
media file serving.</p>
</li>
<li>
<p><ahref="http://www.revsys.com/blog/2014/dec/03/loading-django-files-from-code/">Loading Django FileField and ImageFields from the file system</a>
shows how to load a model field with a file from the file system.</p>
</li>
</ul>
<h2>Open source Django example projects</h2>
<ul>
<li>
<p><ahref="https://github.com/makaimc/txt2react">Txt 2 React</a> is a full Django web
app that allows audiences to text in during a presentation with feedback
or questions.</p>
</li>
<li>
<p><ahref="https://github.com/ustream/openduty">Openduty</a> is a website status checking
and alert system similar to PagerDuty.</p>
</li>
<li>
<p><ahref="https://github.com/myusuf3/courtside">Courtside</a> is a pick up sports web
application written and maintained by the author of PyCoder's Weekly.</p>
</li>
<li>
<p>These two Django Interactive Voice Response (IVR) system web application
repositorities <ahref="https://github.com/phalt/twilio-django-part-1">part 1</a> and
<ahref="https://github.com/phalt/twilio-django-part-2">part 2</a> show you how to
build a really cool Django application. There's also an accompanying
Build a few more simple applications using the tutorial resources found
in the "Django resources" section.</p>
<p><iclass="fa fa-check-square-o"></i>
Start coding your own Django project with help from the
<ahref="https://docs.djangoproject.com/en/dev/">official documentation</a> and
resource links below. You'll make plenty of mistakes which is critical
on your path to learning the right way to build applications.</p>
<p><iclass="fa fa-check-square-o"></i>
Read <ahref="http://www.amazon.com/Two-Scoops-Django-Best-Practices/dp/098146730X/ref=sr_1_2?ie=UTF8&qid=1391562062&sr=8-2&tag=mlinar-20">2 Scoops of Django</a>
to understand Django best practices and learn better ways of building
Django web applications.</p>
<p><iclass="fa fa-check-square-o"></i>
Move on to the <ahref="/deployment.html">deployment section</a> to get your Django
project on the web.</p>
<h3>What do you need to learn next for your Django app?</h3>
<h1>Flask</h1>
<p><ahref="http://flask.pocoo.org/">Flask</a> is a Python web framework built with a
<ahref="http://flask.pocoo.org/docs/design/">small core and easy-to-extend philosophy</a>.
<li><ahref="http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvi-debugging-testing-and-profiling">Part 16: Debugging, Testing and Profiling</a></li>
<li><ahref="http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvii-deployment-on-linux-even-on-the-raspberry-pi">Part 17: Deployment on Linux</a></li>
<li>
<p><ahref="http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xviii-deployment-on-the-heroku-cloud">Part 18: Deployment on the Heroku Cloud</a></p>
</li>
<li>
<p>If you're looking for a fun introduction to Flask and WebSockets, check out
my blog post on creating
<ahref="https://www.twilio.com/blog/2014/11/choose-your-own-adventure-presentations-with-reveal-js-python-and-websockets.html">Choose Your Own Adventure Presentations with Reveal.js, Python and WebSockets</a>.
That post is my favorite technical walkthrough I've written to date. There
for the app with tags for each step in the blog post.</p>
</li>
<li>
<p><ahref="https://www.twilio.com/blog/2014/10/branded-mms-coupon-generation-with-python-and-twilio.html">Branded MMS Coupon Generation with Python and Twilio</a>
is a Flask tutorial I wrote for building a web application that can send
branded barcode coupons via MMS. The post goes through every step from
a blank directory until you have a working app that you can deploy to
Heroku.</p>
</li>
<li>
<p><ahref="http://blog.john.mayonvolcanosoftware.com/building-a-blog-using-flask-and-angularjs-part-1/">Building a blog using Flask and AngularJS Part 1</a>
is the first of a multipart series on working with Flask and an AngularJS
front end.
<ahref="http://blog.john.mayonvolcanosoftware.com/building-a-blog-using-flask-and-angularjs-part-2/">Part 2</a> is also available
<ahref="https://github.com/basco-johnkevin/building-a-blog-using-flask-and-angularjs">along with the source code</a>.</p>
</li>
<li>
<p><ahref="http://flask.pocoo.org/extensions/">The Flask Extensions Registry</a> is a
curated list of the best packages that extend Flask. It's the first location
to look through when you're wondering how to do something that's not in the
core framework.</p>
</li>
<li>
<p><ahref="http://exploreflask.com/">Explore Flask</a> is a public domain book that
was previously backed on Kickstarter and cost money for about a year before
being open sourced. The book explains best practices and patterns for
building Flask apps.</p>
</li>
<li>
<p>Randall Degges wrote a detailed walkthrough for
<ahref="https://stormpath.com/blog/build-a-flask-app-in-30-minutes/">building a Flask app in 30 minutes</a>.</p>
</li>
<li>
<p><ahref="http://charlesleifer.com/blog/saturday-morning-hacks-building-an-analytics-app-with-flask/">Building an Analytics App with Flask</a>
is a detailed walkthrough for collecting and analyzing webpage
analytics with your own Flask app.</p>
</li>
<li>
<p>Nice post by Jeff Knupp on <ahref="http://www.jeffknupp.com/blog/2014/01/29/productionizing-a-flask-application/">Productionizing a Flask App</a>.</p>
</li>
<li>
<p><ahref="http://maximebf.com/blog/2012/10/building-websites-in-python-with-flask/#.U06EZ-ZdW4J">Building Websites in Python with Flask</a>
is another walkthrough tutorial from first steps through
<ahref="http://maximebf.com/blog/2012/11/getting-bigger-with-flask/">getting bigger with Flask</a>.</p>
</li>
<li>
<p>The Plank & Whittle blog has two posts, one on
<ahref="http://www.plankandwhittle.com/packaging-a-flask-web-app/">Packaging a Flask web app</a>
and another on
<ahref="http://www.plankandwhittle.com/packaging-a-flask-app-in-a-debian-package/">Packaging a Flask app in a Debian package</a>
once you've built an app and want to deploy it.</p>
shows how to build a task queue with Flask and Redis.</p>
</li>
<li>
<p>Along with the above FLask by Example series, there's also a
<ahref="https://github.com/realpython/discover-flask">Discover Flask</a> series of
videos. The GitHub repo contains the code and the 25+ videos are hosted
on YouTube.</p>
</li>
<li>
<p><ahref="https://www.digitalocean.com/community/articles/how-to-structure-large-flask-applications">How to Structure Large Flask Applications</a>
covers a subject that comes up quickly once you begin adding significant
functionality to your Flask application.</p>
</li>
<li>
<p><ahref="http://blog.miguelgrinberg.com/post/video-streaming-with-flask">Video streaming with Flask</a>
is another fantastic tutorial by Miguel Grinberg that covers video
streaming.</p>
</li>
<li>
<p>"<ahref="https://medium.com/@5hreyans/the-one-weird-trick-that-cut-our-flask-page-load-time-by-70-87145335f679">One line of code cut our Flask page load times by 60%</a>
is an important note about optimizing Flask template cache size to
dramatically increase performance in some cases.</p>
</li>
<li>
<p><ahref="https://www.twilio.com/blog/2014/03/unit-testing-your-twilio-app-using-pythons-flask-and-nose.html">Unit Testing Your Twilio App Using Python’s Flask and Nose</a>
covers integrating the Twilio API into a Flask application and how to test
that functionality with <ahref="https://nose.readthedocs.org/en/latest/">nose</a>.</p>
</li>
<li>
<p>The Flask documentation has some quick examples for how to deploy Flask
provides a thorough view of basic concepts and features for the framework.</p>
</li>
<li>
<p>Digital Ocean provides an extensive <ahref="https://www.digitalocean.com/community/articles/how-to-use-the-bottle-micro-framework-to-develop-python-web-apps">introductory post on Bottle</a>.</p>
</li>
<li>
<p>This tutorial provides a walkthrough for
<ahref="http://www.giantflyingsaucer.com/blog/?p=3598">getting started with Bottle</a>.</p>
</li>
<li>
<p>Here's a short code snippet for
<ahref="http://myadventuresincoding.wordpress.com/2011/01/02/creating-a-rest-api-in-python-using-bottle-and-mongodb/">creating a RESTful API with Bottle and MongoDB</a>.</p>
presentation goes over Bottle, Flask, and many other lesser known Python
web frameworks.</p>
</li>
<li>
<p>A Python newcomer asked the Python Subreddit to
<ahref="http://www.reddit.com/r/Python/comments/28qr7c/can_anyone_explain_the_differences_between_web2py/">explain the differences between numerous Python web frameworks</a>
and received some interesting responses from other users.</p>
</li>
</ul>
<h2>Other frameworks learning checklist</h2>
<p><iclass="fa fa-check-square-o"></i>
Read through the web frameworks listed above and check out their project
websites. </p>
<p><iclass="fa fa-check-square-o"></i>
It's useful to know what other web frameworks exist besides Django and Flask.
However, when you're just starting to learn to program there are significantly
more tutorials and resources for <ahref="/django.html">Django</a> and
<ahref="/flask.html">Flask</a> on the web. My recommendation is to start with one of
those two frameworks then expand your knowledge from there.</p>
<h3>What do you need to learn next?</h3>
<h1>Deployment</h1>
<p>Deployment involves packaging up your web application and putting it in a
production environment that can run the app.</p>
<h2>Why is deployment necessary?</h2>
<p>Your web application must live somewhere other than your own desktop or
laptop. A production environment is the canonical version of your current
application and its associated data.</p>
<h2>Deployment topics map</h2>
<p>Python web application deployments are comprised of many pieces that need to
be individually configured. Here is a map that visually depicts how each
deployment topic relates to each other. Click the image to pull up a PDF