Cup of Django

How much Python do I need to learn for Django?

Recently, someone on Reddit posted a question asking how much Python one needs to know before moving on to Django.

That’s a great question.

Learning Python can take a long time! You wouldn’t want to spend years “learning” Python before moving to the fun stuff.

You want results much sooner than that!

In fact, I would say one of the best ways to get better at Python (but not necessarily learning from scratch) is through Django. People always recommend getting better at Python through doing. Using Django to build web applications is one way of “doing”!

That being said, you do need to have some fundamentals in order to use Django at all, otherwise a lot of things won’t make sense.

But then how do you know when you’ve learned “enough”?

The bare minimum

I will tell you what I recommended to do Django at a basic level.

If this seems like a lot, don’t worry. If you work at it, you will learn everything here and more.

You should ask yourself the following questions. If you say “yes” to all (or most of them), you are well equipped to move on to Django.

If not, I suggest working at them in this specific order.

1. Basic program flow

Can you write simple scripts that take basic input and output?

Do you know how to write if statements?

2. Working with collections

Do you know the differences between a list, a tuple, a dict and a set? Do you know why each one is used?

Do you know how to iterate through them using for loops and while loops?

Do you know how to write basic list and generator comprehensions?

3. Working with strings

Do you know that a string is also something you can iterate over, like a list? Do you know how to do that?

Can you do basic string formatting? For example, can you take a variable and create a string that contains that variable?

4. Writing and using functions

Can you write a function?

Do you know how to specify arguments and keyword arguments in your function, and how they work?

5. Using decorators

Do you know what a decorator is, and how to use it?

(Knowing how to write one is optional right now)

6. Modules, packages, and libraries

Do you know what Python modules and packages are?

Do you know how to import something from a module or a package? Do you know that you can import variables, functions, classes, as well as other modules and packages?

Do you know at least one way to install a Python library?

7. Object-oriented programming

Do you know what a class is?

Do you know what an object is?

Do you know how to write a class?

Do you know what __init__() does?

Do you know the difference between a function and a method?

Do you know how to instantiate a class to create an object?

Do you know what inheritance is, and how to write a class that inherits from another class?

Do you know what a Mixin is and how to use it?

That’s all!

That’s the minimum, I believe, that you need to know about Python to work with Django at a basic level.

I say “minimum”, but don’t let that fool you!

Let me tell you a secret: 95% of the time, everything contained in the list above is more than sufficient to write a Django application.

In fact a lot of the production code I deal with rarely deviates from the list above.

So, there are a lot of things there.

If you already know everything there, congratulations!

Otherwise, I recommend working on it step-by-step, as mentioned, in the same order as above.

Wrapping up

I am preparing a more detailed cheat sheet that contains basic information about every item in the list above.

If you would like to hear about it when it’s ready, make sure you join my mailing list. I will be sure to update you when it’s ready.

Thanks for reading!

Join the Cup of Django mailing list

Like these posts? Sign up to receive 4-5 emails a month about Django.