Skip to content

TheCodingDojo/django_modularized_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This example demonstrates some more advanced patterns

Optional Advanced Topics

  • only try these if you are not struggling with the more basic patterns you first learn in django

named routes

  • giving routes a name can help with readability and if the URL ever changes, since everywhere that the route is referenced it is referenced by name instead of by the URL, you only have to update the URL in the one place

multiple views & template sub folders - better organization

  • Splitting views is useful when you have more than one model, e.g., User and Task and you want to have a route for all users and a route for all tasks, you can't have the two view functions with the name 'all' and two html files named 'all' unless they are split into separate view files and separate template sub-folders
  • implemented in same way as multiple views

base.html pattern & include

  • include is used to include all the HTML from another file, can be used for re-usable or just separating out a distinct section of HTML to keep things from getting bloated
  • Django Girls base.html tutorial
  • create a block in the head of the base.html that you can use to inject stylesheet <link> tags into from other html files
    • e.g., your extension html file has it's own personal stylesheet that you need the base.html to load
  • create a block in between the <title> if you want each page to be able to set the <title> of the html page

Fat models, skinny views

  • move all the logic that relates to the model onto the model itself to keep that separate from the views (separation of concerns)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published