• 12 heures
  • Moyenne

Ce cours est visible gratuitement en ligne.

course.header.alt.is_video

course.header.alt.is_certifying

J'ai tout compris !

Mis à jour le 20/07/2022

Get the Most Out of This Course

Meet Your Teachers

Patrick Heneghan, from the UK, has been a software engineer since 2007, and has been working with Python since 2013. He uses Django and other MVC/MVT frameworks in the systems he builds.

Rafiq Hilali is a senior full-stack software engineer working with Lambert Labs. Specializing in Python, he has architected and delivered several production-grade Django applications. Originally from the UK, Rafiq uses his career as a developer to travel and work worldwide, from places like Indonesia and New Zealand to the Philippines and Canada.

Learn From a Professional Scenario

In this course, you will create a full web application from start to finish. The context of this web application is outlined below:

You’ve been asked to create a proof of concept for a new web app: the Merch Exchange. This will be an app where people can list various collectible music merchandise like records, posters, and gig tickets. In addition, users should be able to post listings of the merch they would like to sell.

Using Git

While you work on this project, I strongly recommend tracking your code in Git.

In the first few chapters of the course, I’ll cover initializing your repository and make suggestions for your .gitignore file, but I’ll be leaving the rest up to you.

You can also use the course GitHub repository for reference.

Reading the Code Samples

You’ll notice that some of the code samples have ellipses in them (  ...  ) - this denotes areas where I have omitted code to keep the samples brief. This is because we will often have to edit files with many lines of code, and it wouldn’t make sense to show the whole file every time.

Using the Terminal (aka the Shell, or the Command Prompt)

There are many terminals available on different operating systems, and they all display output and input in different ways. But the basics are always the same:

  • You type commands into the terminal (input).

  • You get lines of text back (output). 

Whenever a terminal is ready and waiting for you to type something in, you will see a prompt that might look like:

  • $

  • C:\>

To keep things simple, the terminal code samples in this course will use a    to signify the prompt.

Wherever you see the    sign in terminal code samples, you should type any text that comes after it (not including the    sign) and then type Enter to run it. For example:

→ ./manage.py runserver

Prompts in terminals will often be preceded by the current directory path to remind you where you are. We’ll use a similar format in the code samples, so you’ll always know where you should be before you run a command:

~/projects/django-web-app/merchex
→ ./manage.py runserver

 If you’re unclear which directory you’re in, you can run the  pwd (“print working directory”) command at any time to remind yourself which directory you are in, e.g.: 

→ pwd
~/projects

Other lines that do not begin with  represent the output of whatever command we just ran. But, again, you don’t need to type this out; it’s just there for you to follow along. And remember, what you see in your terminal might look a bit different from what’s in the code samples. 

In the Django shell, the prompt looks like this:

>>> 

Unless you have IPython installed, in which case it looks like this:

In[1]:

The code samples in this course are written in the former style. So you will see code samples like this:

>>> from bands.models import Band 

Again, you should type everything after (not including) the  >>>  and hit Enter to run it.

You can refer to this useful list of Linux commands alongside their Windows equivalents.

Coming Back to the Project After a Restart

You should always have your virtual environment activated during development. For example, if you restart your machine and then come back to the project, you can activate your virtual environment by first making sure you’re in the directory that contains your  env  directory and the running: 

→ source env/bin/activate

If Your Site Has Stopped Working

From time to time, you may notice that the development server crashes while you’re coding.

Don’t panic - this will happen a lot while you’re developing. The development server automatically reloads your code for you whenever it detects you’ve saved something new in one of your files.

This is often really handy, but it also means that if your code is incomplete, the server will automatically reload your unfinished code and could crash.

Remember that some IDE’s (including PyCharm) use an auto-save feature, triggering a reload of the development server without a manual save!

Often the server process will stay running and wait for the next change, at which point it will start up again.

Occasionally though, the server is unable to recover from the error. In this case, you may want to finish the code you’re writing, then switch to the terminal and:

  • Get back to a prompt in the terminal (if you don’t see one already) with Ctrl-C.

  • Ensure you are in the correct directory - if you issue the  ls  command, you should be able to see  manage.py  . If you can’t see it, navigate to the directory that contains this file, e.g., with  cd bandub  .

  • Restart the development server with   ./manage.py runserver  .

Now that you know how to take this course, you're ready to install Django! 

Exemple de certificat de réussite
Exemple de certificat de réussite