2 Your first Django site

 

This chapter covers

  • Creating a Django project
  • Django projects and apps
  • Creating a Django app
  • Running the development server
  • Writing a Django view

In this chapter, you’ll start your Django coding journey by taking the first steps toward building a website for musicians and bands. You’ll create your first web page using the Django framework: a credits page showing who built the site.

2.1 The RiffMates project

Your cousin Nicky is a guitarist, and she has a great idea for a website: classifieds for musicians. The site will cater to musicians looking for bands, bands looking for musicians, venues looking for bands, and bands looking for gigs. Nicky even has a name picked out, RiffMates. Over coffee, you and Nicky have talked at great length about what the site needs, including the following:

  • Profile pages for musicians, bands, and venues
  • Classified ad listings
  • Announcement listings for tryouts
  • Search capabilities based on instruments played and style of music
  • Messaging between potential matches

Nicky has confidence in your coding skills because you’ve talked excitedly about the Python you’ve learned in the past. As you think about the problem, you realize that those features are just the business requirements. To build a working website that can do all those things, you’ll also need features that are common to most websites, such as

2.2 Creating a Django project

2.3 Projects vs. apps

2.4 Your first Django app

2.5 Your first Django view

2.6 Registering a route

2.7 Visiting your view

2.8 Exercises

Summary