How To Plan A Django Project

I am a new Django developer, and one of the things that seemed difficult for me at first was getting started. I looked at my employer's large Django projects, with their multiple apps and multiple layers, and felt overwhelmed at the thought of trying to build my own robust Django project.

What is the best way to get started on such a feat? The answer is simply this: Good, old-fashioned planning.

Start with these questions

Whenever you begin planning, you have to ask yourself a few questions. Some of the questions that can help you in the planning phase of your Django project include the following:

  • What is the purpose of your Django project?
  • What functionality does your project need to have to meet that purpose?
  • Which models will you need to have for your project?
  • What relationships between models will you need to make?
  • What do you want to use for handling the front-end of the site?

At this stage, you only need to jot down a few answers to these questions. You will need to expand them in the next planning step, but this will help to point you in the right direction.

Plan your structure

Now you need to have an idea of what structure you will have to have. Are you going to have multiple apps to handle different parts of the project? Are you planning on using Python/Django packages instead of recreating the wheel? You can map out your project's structure on a piece of paper, or use a virtual whiteboard.

The structure of your Django project determines how each component of it works together. If you know ahead of time how you want to handle the relationships between your apps, it makes it that much easier to do it. It also makes a solo project less overwhelming!

Determine your models

One of the things that I have learned over the last few months at my apprenticeship and in my coding bootcamp is that Django is really all about models and their relationships with each other. In the bootcamp (Coding Dojo shoutout!), we used the MySQL Workbench tool to make an Entity Relationship Diagram (ERD) — a visual representation of your models and how they connect. This is helpful because then you can visually identify whether your model needs a One-To-Many or Many-To-Many relationship with another model.

You can also take it out a piece of paper and write down the fields that you want your models to have, how they connect, and what the related names will be for your fields in the models that they have a relationship with. I like doing this because then I can see what I need to reference in any CRUD commands that I use in my views or in my templates.

Don't forget the front-end

Of course, you want to build your database models before you start working on the front end of your site; however, the front end is very important. This is where your users or site visitors will interact with your project. How can you make it the best experience for them? Just as you planned the Django back-end for your project, you also need to plan for the front-end.

You could create a front-end prototype of your site on Figma or in Photoshop that shows how people may navigate your site. If you like pen and paper, it's okay to wireframe your site in that format, too. Do whatever works for planning the front-end of the site and understand what it needs to have for people to use your site.

That is all that I have for now! I hope to eventually begin adding some tutorials on the things I have learned. Django is a great back-end framework, and I enjoy working with it. Until next time....