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/models.py
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/models.py
file with the following lines. The new code creates a Game
class, specifically, a Game
model in the games/models.py
file. The code file for the sample is included in the restful_python_2_05_01
folder, in the Django01/games_service/games/apps.py
file:
from django.db import models class Game(models.Model): created_timestamp = models.DateTimeField(auto_now_add=True) name = models.CharField(max_length=200, default='') release_date = models.DateTimeField() esrb_rating = models.CharField(max_length=150, default='') played_once = models.BooleanField(default=False...