Importing data from an external JSON file

The music website has an API under the domain that you can use to read the albums, artists, tracks, events, and more. The API allows you to either use the JSON or XML format. In this recipe, we will import the top tracks tagged disco using the JSON format.

Getting ready

Follow these steps in order to import data in the JSON format from

  1. To use, you need to register and get an API key. The API key can be created at
  2. The API key has to be set in the settings as LAST_FM_API_KEY.
  3. Also, install the requests library in your virtual environment using the following command:
    (myproject_env)$ pip install requests
  4. Let's check

Get Web Development with Django Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.