Creating the models

Now we will create a simple Game model that we will use to represent and persist games. Open the games_service/games/ file. The following lines show the initial code for this file, with just one import statement and a comment that indicates we should create the models:

from django.db import models 
# Create your models here. 

Replace the code for the games_service/games/ file with the following lines. The new code creates a Game class, specifically, a Game model in the games/ file. The code file for the sample is included in the restful_python_2_05_01 folder, in the Django01/games_service/games/ file:

from django.db import models class Game(models.Model): created_timestamp = models.DateTimeField(auto_now_add=True) ...

Get Hands-On RESTful Python Web Services - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.