Introduction
When it comes to Python for web development. I feel that it is really not talked about much. Since the upward trend & popularity for Python has been towards Data science in recent years due to popular tools like Pandas, Keras, Tensorflow and the attractiveness of Data Science.
It is hard to find a web developer that uses Python. It is harder for a Django one. This comes from me being in a startup that uses Django for backend and talking to multiple friends who are CTOs from Startups as well who are hiring Full Stack Python developers.
My usual advice when talking to them is to search for ways to train them from the ground up. Especially for people who have fundamentals in programming, in general, to increase your pool of python web developers.
Data Science
Since I am on the subject of Data Science for web development. I found that the usual practice for Data Scientist who use Python. They will be just using Flask for APIs development. Due to its flexibility & ease of building API or using Data visualisation tools like Matplotlib, Streamlit & Plotly.
For this subject, I talk in detail regarding the pain of developing these dashboards or data visualisation. Nevertheless, it is due to the ease of not needing to understand the various intricacies of web development. To create a highly interactive & functional dashboard that is served or shared through a website internally or externally.
On a practical level, learning web development for Python helps in the ease of transition from a web developer using Python. To building APIs, data visualisations & union of both web development and data science world.
Which Web Framework Should I Learn?
If you're serious about web development for Python. I would suggest you learn Django. Due to its force multiplier capabilities that allow high scalability, batteries included philosophy, security & ease of rapid prototyping.
With the price of being daunting with a steep learning curve. As it uses certain best practices to allow ease of development like having a fix project structure and Model-View Template Pattern (MVT).
API First
If you are using either Flask or Django. i assume that you are building it for a backend in the form of either RESTful APIs, GraphQL & gRPC.
Therefore understanding how to create documentations like Postman, Swagger Editor or adopting API standards like OpenAPI along with understanding testing & mocking can be really helpful in the adoption of your API.
Since great documentation is the key for anyone to adopt an API and integrate into their product or services. You can look at either SalesForce, Twilio, DigitalOcean, Stripe as a great source of inspiration for creating excellent technical documentation.
Conclusion
Lastly, it makes more sense to be a Python web developer because of the low barrier of entry with a niche as either a Flask or Django developer. Instead of using Python for Data Science purposes which may require a higher level of education requirements for jobs and understanding complex algorithms in AI or ML or Data analysis.
If you like this article do sign up for my Adventurer's Newsletter for my Adventurer's newsletter which contains interesting content I stumble across over the week in the area of Python, Web Development, Startup.
You can also follow me to get the latest update of my article on Dev
The original post was on Python For Web Development - Reading Time: 3 Mins and cover image by Sam Erwin on Unsplash
Reference
- Python for Beginners
- APi First Business
- Install Python 3.8 and Django 3.0 + on Windows 10
- Creating Dashboard to Visualise Data in Python
- Flask
- Django
- Steamlit
- Plotly
- Matplotlib
- Model-View Template Pattern (MVT)
- Python Tutorial For Begineers
- Getting Start with Django
- Full Stack Python
- Cookiecutter
- Simple is Better Than Complex
- Python Web Development
- Postman
- Swagger Editor
- OpenAPI
- Cosmic Python, TDD, testing and external dependencies - Harry Percival
- SalesForce
- Twilio
- DigitalOcean
- Stripe
- Coding for Entrepreneurs
- CleverProgrammer
Top comments (12)
Out of curiosity, why recommend Django over Flask?
(disclamer: I work in Flask, never wrote anything in Django, but have some idea about how it works - also work with Rails, which I guess is a similar beast)
I would guess it's because of simplicity of making basic app. If you main goal is to provide web interface for data manipulation (dashboards, APIs), there's little need to understand how it works and write everything yourself (as you will probably do when starting in Flask until you find all the right plugins and/or write abstractions you need).
Yup it's actually a replica of Ruby for Django. Which is why data scientists will work with Flask more than Django.
Due to its huge learning curve that follows to just to understand it and use it fully because you are really going past the microservice and API aspects of it.
Are you saying flask has a huge learning curve while also advocating Django? Or am I misunderstanding? I've done professional work in both; flask was significantly easier to get people productive in fastest but I did lay solid foundations following good patterns and recommended extensions like flask-talisman and co.
Ahh.. its my bad I wrote wrongly. I was referring to Django for steep learning curve.
To me it is more like of a overkill to use Django. Which Data Scientists just prefer to get it done with a quick & dirty solution.
Depending on who you talk to they might not even know of the concept of clean code or TDD.
When they are building a data product as it is not part of their job to do it.
Django has security built-in by default.
You do more with less, without the need to code everything by yourself.
Because of their batteries included philosophy like Object Relationship Mapping (ORM), customisable Admin Panel, Account Management with a very wide 3rd party ecosystem.
Which if you want to do it yourself, you need to explore multiple types of python packages.
Don't get me started in projects structures for Flask. Which the last good option was to use cookiescutter to help you set it up because there is literally 2 or 3 way to build Flask that differs greatly.
Which you need to have a consensus to structure your project.
In a way so that it is easy to maintain but it requires your understanding of concepts to abstract parts of your code and manage the project structure correctly.
Just a quick thought on learning web dev vs actual web dev:
Maybe Bottle is the best to start off with as it is the easiest. It inspired Flask and similar enough that learning Bottle will transfer very easily to learning Flask.
Then, perhaps, FastAPI is the python framework to learn next. Again, very Flask-esque, but just a more modern implementation.
Hmm... It depends I'm a person that is inclined to depend on the use case and the types of jobs that is available in your country. So to learn that particular technology and practices.
So far for jobs wise the popular choice I see is either Flask or Django as a must if you are looking for anything related web development in python.
Therefore I'll pass on bottle but definitely FastAPI is in my radar as I had heard praises of it. So I'm thinking of learning it as well in the future and write a article on it.
Given that, I'll give a higher priority on other topics like learning a frontend web framework, CSS grid or Flexbox, GraphQL, typescript or ES6, cloud providers, TDD, clean code, design patterns.
Lastly with soft skills related topics to improve one's ability to be a better developer.
Definitely. For jobs, you'd need to go with what is popular in the field/industry/area.
But "learning" though... Bottle wouldn't take more than a day to "learn". Not even an hour, even for a beginner. Sure having the mastery to make something deployable takes a lot of practice in any framework or tools.
But I am talking about the pedagogical value here. Bottle won't require the learner install much or do much project set up or configuration at all.
Within minutes of starting, even to an entirely new beginner, you can get to an "ah that's what you mean by a backend", and "ah that is what an api is" and so on.
Much in the same way that Svelte would be a more gentler intro to the front end than React or Angular are for a beginner. Even though, eventually you'll need to learn the tool you need to get a job or do a job.
Anyways, Flask "hello world" is simple enough.
Yup Flask's hello world is simple enough and it won't take less than 1 hour to do it.
In terms of learning method wise, the best Flask or Django tutorials that I was watching uses bootstrap to cover the front-end portion using Django or Flask's templating engine.
Instead of diving deep in using a front-end web framework like Svelte, React, Angular or Vue. Since there are tons of beautiful and well-maded templates Creative Tim.
Which you can modify those pre-made templates to get what you want that any Flask or Django developer with a good foundation in CSS, HTML, Javascript can do it.
I love Python for web apps! I also recommend to use Django for most of the cases.
By the way, check out this awesome Django project template: it allows to start new Django projects filled with best-practices and good tools in just a few clicks.
Features:
python3.7+
poetry
for managing dependenciesmypy
and django-stubs for static typingpytest
andhypothesis
for unit testsflake8
and wemake-python-styleguide for lintingdocker
for development, testing, and productionsphinx
for documentationGitlab CI
with fullbuild
,test
, anddeploy
pipeline configured by defaultCaddy
withhttps
andhttp/2
turned on by defaultwemake-services / wemake-django-template
Bleeding edge django template focused on code quality and security.
wemake-django-template
Bleeding edge
django2.2
template focused on code quality and security.Purpose
This project is used to scaffold a
django
project structure Just likedjango-admin.py startproject
but better.Features
python3.7+
build
,test
, anddeploy
pipeline configured by defaulthttp/2
turned on by defaultInstallation
Firstly, you will need to install dependencies:
Then, create a project itself:
Who are using this template?
If you use our template, please add yourself or your company in the list.
We offer free email support for anyone who is using this If you have any problems or questions,…
Some comments may only be visible to logged-in visitors. Sign in to view all comments.