Django – Making a simple web app with 4 links

The idea of the article is to show how to make a simple Django App, with 4 links, each of which navigates to a specific page. The whole code of the “app” is in GitHub, here:

https://github.com/Vitosh/Python_personal/tree/master/JustProject. In general, these are the 4 pages:




Not a lot, but if you take a good look at the URLS, you will notice that we have 2 apps actually – justcode and vitoshacademy. In order to create these two apps, the following code is called from the console

And these are having each two separate pages, as displayed on the picture below:

So, there are “python.html” and “vba.html” for justcode and “about.html” and “info.html” for vitoshacademy. In order to make the simple 4 pages working, we need to assign the URLs of the main app JustProject (JustProject/JustProject/urls.py) to the local apps:

  • VitoshAcademy (JustProject/VitoshAcademy/urls.py)
  • JustCode (JustProject/JustCode/urls.py)

This is done the following way:

The Views of the 2 smaller apps are the ones, that hold the logic and navigate the direction to which the app should go in order to find the html files:

So, the views navigate towards the html folders. However, the html folders look a bit strange – e.g. vba.html consists only of these 4 lines:

And yet, there are some links on the top of it. These are in stemplates/shared/site.html

If you take a good look, this one includes something called partials/nav.html, which is where the actual links are. They are present only once, but used for each page:

Well, this is all I guess. The rest would concern some changes in the settings which is present in GitHub. 🙂

Tagged with: , , , , , , ,