Applications in Django

Previously On Django.

In our previous sections, we looked at how to set up a django project from scratch: we downloaded python, installed pip, created and activated our virtual environments,

created a new django project called Nounews and even saw the django rocket in our browser all ready to take off. Yes, we are ready to take off now. We are ready to start customizing our django project to suit our need, that is, a news web application.

Applications In a Django Project

You could view the project(Nounews) as your whole web application, and within this web application will be different parts: accounts for registration, logging user activities, resetting passwords among others.

We could also have another part for managing our news, that is, creating, editing and updating, deleting, and viewing our actual news contents. 

These various sections (accounts,news, etc) are what we refer to in django as apps (applications).

So different apps will handle different parts of the whole web application but they will seamlessly work together on the same domain, in this case, our domain is our localhost: http://127.0.0.1:8000/. In a production case, your domain name could have been www.pywe.org.

So usually, when you see a url like this www.pywe.org/accounts/ the accounts part represents a particular application within the project, you would see something like www.pywe.org/accounts/login/ as the url for a login page. Meaning the login implementation has been handled under the accounts application. The login part would usually be directed towards a function in the views.py file which is located in the accounts application.

Applications make things intuitive

This separation does not only make things clearer but easier while working with the project, you are able to classify in your mind's eye where a certain business logic or implementation should take place and the overall sitemap or site structure for your website becomes very intuitive.

We will go on to creating our first application which will be called accounts as well for user management. I strongly recommend you create this as your first application in any django project unless of course there will be no need for user management at all.