0x001A - Django - URLs, Templates, Apps, DocUtils

0x001A - Django - URLs, Templates, Apps, DocUtils

Django works with three major building blocks in it's MVC (Model / View / Controller) model:

  • URLs
  • Templates
  • Apps

URLs: Define entry points to access content (urls.py)

Templates: Define the end points that give form to the final content (html files)

Home page for Django


Apps: serve as the middle-ware between urls and templates, altering or adding content. (apps folder)

Starting a new project:

django-admin startproject testproject

Static Content: urls and templates.

Dynamic Content: urls, templates, and Apps.

An example of creating a view as a class object:

Which is then added to the urls as in:

Adding Documentation to the /admin section:

  • Next we want to look at adding the documentation to the /admin/ section.

A. Add to your INSTALLED_APPS: 'django.contrib.admindocs'

B. Add the urlpattern for it:

C. It informs us that we need to add 'docutils'

It is best to install it to the global environment instead of the one local to PyCharm for that project.

After this point we have docutils working:

Linux Rocks Every Day