16 Tips for Python and Django beginners

So you have decided to learn Python or Django. Maybe you are already learning the language and the framework. Well, I have 16 Tips for Python and Django beginners for you to speed up your learning.

First steps
1.- Master the fundamentals
2.- Start solving problems
3.- Build small, simple projects
4.- If you are new to web development, start with Flask
5.- Jump to web Development with Django
After the basics
6.- Learn new Django concepts
7.- Start using those new concepts
8.- Read code from other people
9.- Surround yourself with people learning
10.- Surround yourself with professionals
11.- Read Django books
12.- Code every day
13.- Take breaks
14.- Ask others
15.- Teach others
16.- Build something
Conclusion

Master the fundamentals

training-wheels

Master the fundamentals, get your basics down. Thanks to Python’s syntax, it is possible to use Django without being a master of Python, as it is very friendly for new programmers. Python code looks like English language, as you can see:

fruits = ['apple', 'orange', 'cherry']
for fruit in fruits:
    print(fruit)

> apple
> orange
> cherry

Despite that, you need to learn the basics to fully understand what Django it is doing behind the scenes.

I have learned Django after a few months of knowing Python and I managed to more or less understand it. But after studying it more deep, without touching Django, I can say I finally UNDERSTAND Django.

So learn your basics as the first step towards learning Django.

Here’s my Python tutorial if you need help: Python tutorial

Start solving problems

You have mastered the fundamentals. You have the building blocks of the Python language. Now it is time to solve small problems.

Create a function that can calculate taxes. Create a loop that keeps asking the user for a number (age, for example?) until the users stops the loop and calculate the average of all ages.

There are even websites where you get small challenges to you to solve them. You get points based on the answer and you start ranking up. Some of those websites are HackerRank and CodeWars.

Build small, simple projects

If you can solve small problems, why not start having fun by building something?

We have learned Python to solve bigger problems such as “I need a website where I can buy tickets” or “I need a program that can search for a name and a surname within a bunch of excels”. Ok, let’s do it then!

Build small projects in Python and start increasing the difficulty. Don’t try to build a Youtube alternative on your own (at least, not yet!).

Start building something simple, something you can have fun with. A game of Rock-Scissors-Paper, a Tic-Tac-Toe or a Guess the number game.

rock-scissors-paper

Once you have build it, go and build another one. Or take the one you have and start adding features.

You have managed to create a Rock-Scissors-Paper program? Good. Why no save your score? Learn how to create and write files.

Why not create a Top 10? Learn how to update files to reorder the Top 10.

I know, I know. It is hard, you are going to spend a lot of time Googling and asking for help. Good. It is the best way to learn.

Optional: Start with Flask

If this is your first time learning a programming language/web development and you want to learn Django, a good idea is to start with Flask.

flask-logo

Flask is a good alternative to Django: It is simpler and easy to learn.

Django is a “batteries-included” framework. That means that Django has a collection of libraries and functionalities that lets you, with little programming by your side, do a lot of things, because common stuff we do day to day it is simplified behind the scenes.

It may seems like this is way better. But you are learning and you need to discover how this web development world works.

Flask is a good introduction for that, as it has a lot of functionalities, but they had to be implemented like you, unlike Django.

With Flask, what you see is what you have. Nothing more, nothing else. And well, it is pretty damn easy:

from flask import Flask
app = Flask(__name__)


@app.route('/')
def hello_world():
    return 'Hello, World!'

if __name__ == '__main__':
    app.run()

This is the Flask equivalent of ‘Hello, World’. You just import Flask, create a Flask object and a method is added. If you visit its route, ‘/’, you’ll get a Hello World.

With Django….well, let’s say it is a bit more complicated 😉

So by now, learn Flask. Don’t worry, you have plenty of resources to learn it

Jump to web Development with Django

django

So, you have mastered the basics of Python language and you did your first small programs. Now it is time to learn Django.

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design, and IMHO it is the best Python framework for web development.

It is scalable, secure, fast to develop and uses Python. And we love Python.

Start with the Official Tutorial where you will learn the basics by building a poll application.

After that, do other tutorials. Django girls and TutorialsPoint have a good ones.

If you prefer videos, you cannot miss Corey Schafer, Tech with Tim, JustDjango and CodingEntrepreneurs.

There is other people as Traversy Media or The Net Ninja who are excellent teachers but they lean more towards the FrontEnd, so you won’t see too much from them about Python or Django. But if you like FrontEnd stuff, they are a great source of learning material.

After the basics

So you have now learnt Python and started playing around with Django. You can keep doing tutorials…but you are here to learn and improve, right? Let’s see what we have to do after learning the basics.

These tips are things you have to do periodically, almost everyday. They are not stepping stones, they are not a goal, but practices you should have to do in order to learn Python, Django and….anything.

From Academind video ‘ What you can reasonably expect to learn in a few hours

Learn new Django concepts

You know how to create a project in Django. How the Model-View-Template pattern works. But there is so much more to learn. So, so, much more (luckily!).

Learn new concepts such as Logging, Authentication, Signals, Web Sockets, Celery, Testing…

Remember, it is not a race. Read carefully the documentation. Try it. Don’t even try to memorize it: Learn how it works. What pieces are moving, why should use that new concept, when we should use it.

And then…

Start using those new concepts

Start using them!

As soon as you learn something new, use it. There is no better way to interiorize something than using it right now.

Create a small pet project where you can use it, or better, add it to a current one.

For example, create a cronjob to periodically (weekly, daily) send a JSON with all the elements in a table.

Don’t you understand what I mean with ‘cronjobs’? Well, you have something more to learn 😁

Read code from other people

If you want to learn how to code like a professional there is no better way than reading code from a professional.

Internet is a great source of information. Why don’t you search for Django GitHub projects?

You can learn a lot by doing so. New ways to import packages and modules, better techniques to create Views, how to create multiple settings.py.

You can even download the project and improve it. And to do so, you need to read, read, read and read the code.

Surround yourself with people learning

teaching-code

Does not this contradict with the previous point? Why should I be surrounding myself with people learning Django???

Because you are on the same boat..

You are learning Django. They are learning Django. Both of you have the same skill level, both of you face the same problems.

Surrounding yourself with people that are learning too gives a sense of camaraderie. All of you are pulling towards the same goal and each one can relay on each other for help. Maybe your problem was solved a few days ago by one of your friends. Why not ask him how he solved it?

Surround yourself with professionals

Wait…what? Your head is spinning now. But I am not contradicting myself.

Your workmates, mentors, friends that have been using Django for a while, can solve high-level questions that beginners can’t.

While a beginner can put in your shoes and knows what are you facing, a beginner can help you so far.

A professional can (and had) solve complex problems and can provide you with the bigger picture.

A beginner may tell you how to do something, but only a professional can tell if your current solution it is the optimal one or not.

Read Django books

Surrounding yourself with professionals sometimes is impossible. Or you can’t ask them freely to involve with you for hours and hours.

Thankfully, we have books.

What I like about books, is that you can learn in a few hours, what years and years took a professional to learn.

No, they won’t turn you into a Django beast, but it will set you on a good path to become a good programmer.

My favourites are ‘Django for Beginners‘ from William Vincent, ‘Build a website with Django 2‘ from Nigel George and ‘Two scoops of Django‘ from Daniel Roy Greenfeld and Audrey Roy Greenfeld.

django-for-beginners

I’m not affiliated with either of the authors. I just believe they are an incredible resource and it helped me a lot early in my career. Google what they are saying about the books and you will see.

Code every day

You should code every day. How much? Well, it depends on your situation.

Working single mothers have a harder time finding the free time they need than teenagers. People that spend most of the day outside working has less time to code. People working as programmers…well, they are already programming. But they need to code outside of the job too.

Whatever the time you can take, code everyday. Even if it is just 25 minutes.

Building a routine of coding every day (instead of coding 10 hours a day for 2 or 3 days, then burn out and not code for a week).

You sleep, eat, brush your teeth every day, right? Add ‘Coding’ too right now.

And, once the routine is settled, you’ll see how you start coding more and more time each day.

For this I recommend you to follow the ‘100 Days Of Code’ challenge. It pushed me to code every day, no matter what. Check the rules and take the challenge too.

Take breaks

After a period of studying or coding you have to take breaks.

Taking breaks helps your brain, not only to rest, but to order what you have learnt studying.

Sometimes I faced a bug for hours, only to solve it when I was taking a shower or resting in my chair, reading Reddit.

It is easy to lose perception of the bigger picture and lock yourself into a piece of code.

It is easy to get frustrated because some concept isn’t clicking in your brain when you have been learning for 2 hours non-stop.

Take a break, rest a bit and come with your mind clear and well-rested.

What I use when I code is the Pomodoro technique.

It goes like this:

  • Code for 25 minutes. No distractions. No mobile phone, not browsing internet, not nothing.
  • After 25 minutes, rest for 5 minutes. Do whatever you want but coding.
  • After the 5 minutes period, code for 25 minutes again. On your 4th rest period, take a bigger one (15-30 minutes)
  • Do this until you don’t have more time to code

This has helped me to focus on my coding like a laser while giving me time to rest. The production I can put when I use the Pomodoro technique is way greater than when I try to “Crush It“. And lets me rest.

You can set an alarm on your clock or phone. There are also apps to use this technique. I use Tomato Timer for this.

pomodoro technique

Ask others

When you are learning, you won’t know a lot of things. Or maybe you don’t know they work. Maybe you can build something but that won’t be the best way to do it.

You will have a lot of questions about coding. And what’s the best way to solve a question? Ask one.

You can learn a lot by just asking people. Ask questions on Reddit, ask questions on StackOverflow (be sure to google it first!), ask beginners, ask your workmates… Hell, you can even ask me.

Sometimes people see like a dishonour to ask somebody a question. It is not. It will help you to grow.

And it is better to ask a “dumb” question (I believe those does not exist…) than don’t ask and put yourself or your company in risk.

Just ask. And you will learn.

Teach others

Teaching others is a good way to learn.

When you learn something, you know how to use it (at least, partially). But when you are teaching others, you need to know not only how to use it, but how it works internally: What it does behind the scenes, what happens if you do this, what happens if you don’t do that, why the developers made it work like this and no other way…

There is a lot of exploration and going deep into the subject when you teach other people.

I noticed that when i started writing my Python tutorial. When I went to teach a topic, I had to learn all about it. I went to the documentation, I read other blogs, I watched videos. I never learnt so much as when I write posts like this one.

Maybe you are thinking right now “Cool, but I am learning Python, I can’t teach people!”. Of course you can!

To teach somebody you just need to be one step further down the learning process.

You don’t need to be a Python Senior programmer to teach how to create a function, how variables work or how to print something.

As soon as you learn something, you can teach it. You should teach it. This way you’ll reinforce what you know.

If you can’t teach to somebody else, why not writing a blog like this one about what you are learning?

Build something

The cornerstone of the process of learning is building something.

building-something

We don’t learn for the sake of learning. We learn to build something we want or something we need.

Tutorials hold your hand but that only takes you so far. Reading books can make you feel like you learned a lot. Participating in discussions with other programmers gives you a lot of important and positive inputs.

But you are only as good as you can prove. And to do so, you have to build something.

Start with something easy. A To-Do list. A small program to do the taxes.

Make mistakes.

Try to solve them.

Browse the internet, ask on Reddit, read StackOverflow, skim over blogposts, do whatever you need until you solve your problem.

It is daunting? Yes. You will feel small, and stupid (It is not just me, right?). It doesn’t matter.

It doesn’t matter because that’s the process of learning. That’s the true process of learning. No one has become successful in something when at the first problem, quit.

Try to build something. Fail. Learn. Have success. Repeat.

If you can only remember one of these 16 tips I gave you today, remember this one.

And remember:

Conclusion

I gave you the steps you need to walk to become a good programmer in Python. Now it is up to you to follow them.

I really hope you become a successful programmer and you keep learning a little every day. And enjoy every moment of it.

And I have a cheat-sheet for you. Download it so you can remember everything.

python django cheat-sheet

Keep writing code every day. Keep reading about Python every day. Keep enjoying doing things with Python. That is the best way to keep improving your Python knowledge.

And sooner than you think, you’ll become a Python Guru.


My Youtube tutorial videos

Final code on Github

Reach to me on Twitter


This post was inspired by the Qazi’s video from Clever Programmer ‘Tips for Python & Django Beginners’.