DEV Community

Cover image for 3 tips for Django Beginners
Prateek Maheshwari
Prateek Maheshwari

Posted on

3 tips for Django Beginners

Django has been a lot popular in backend web development. And if you are reading this article you are either starting your Django journey or maybe are trying to see for ways to improve it.
In this article, I will tell you the three things which will surely help you in your Django journey.
But first what is Django? To put it simply it is a web framework in python.
Now coming back to the 3 tips, let's get started with it :

(1) Use virtual environment

If you have seen some tutorials or guides you already know that the best practices are to use a virtual environment for your Django projects, some of the reasons for this are :

  • It helps in maintaining a clean work-space.
  • When at the end you make the requirements file, only the libraries related to your current project are listed rather than everything on your device.
  • If in any case, things go south your system is safe. Now, how can you create a virtual environment? Let's see : I personally use the library virtualenv for this.

Setting up our virtual environment using virtualenv:

  • Let's install virtualenv first
pip install virtualenv
Enter fullscreen mode Exit fullscreen mode
  • Now let's use this library to make a virtual environment
virtualenv name-of-your-virtual-environment
Enter fullscreen mode Exit fullscreen mode

And we have successfully created our virtual env ;)

Note: Before creating a virtual environment make sure you are in the directory you want to set up your virtual environment in.

(2) Try to maintain a systematic order

This will also help you when you work together with other people. Try to separate out the apps. Let a single app do a particular functioning, rather than bombarding everything in a single app. For example: If you are making a simple blog app, put the user-related stuff such as user login, logout, profile, etc in a single app, and keep the blog CRUD operations in another app.
This will not only look clean but also, it will help you out while fixing bugs or adding some new functionality.
Also, it is a good practice to write comments in different parts of code so that it is more clear for the open-source world.

(3) Deploy your Projects

To showcase your projects it is essential that you deploy them, now if you haven't already heard about GitHub, do acquire the basics of git and GitHub and push your project code on GitHub so that everyone& anyone can check out your code, moreover, to deploy your project and show it's working live to others there are two services which I use and so will recommend :

Heroku
PythonAnywhere

If you want to know more about how to publish your projects on these platforms, I will be writing about that in my next article or you can just follow these tutorials :

How to deploy your Django app on Heroku
How to deploy your Django app on pythonanywhere

Do you have any tips of your own to give to other Django developers? Tell me in the comments!
Thank you for reading! I hope you found this article insightful.

In case you want to connect with me, follow the links below →
LinkedIn | Twitter | Medium | Github

Top comments (10)

Collapse
 
rayvikram profile image
rayvikram

Nice tips. One point of would like to add here. Instead of virtualenv i would suggest to use python3's venv. As it is much easier to use and manage.

Collapse
 
friskycodeur profile image
Prateek Maheshwari

That's a good point Vikram! I just used it while watching some tutorial and never tried to look into something else, :P.
Thanks for pointing it out :)

Collapse
 
anubhavitis profile image
Anubhav Singhal

This is awesome!
Nice work.

Collapse
 
friskycodeur profile image
Prateek Maheshwari

Thanks a ton, anubhav !

Collapse
 
diyajaiswal11 profile image
Diya Jaiswal

Really informative :)

Collapse
 
friskycodeur profile image
Prateek Maheshwari

Glad to hear that, Diya :D !

Collapse
 
geekquad profile image
Aditya Kumar Gupta

Great article 🔥

Collapse
 
friskycodeur profile image
Prateek Maheshwari

Thanks, Aditya! 😊

Collapse
 
rajat2502 profile image
Rajat Verma

Well Written 🔥

Collapse
 
friskycodeur profile image
Prateek Maheshwari

Thanks, Rajat! :D