Skip to Content
Hands-On RESTful Python Web Services - Second Edition
book

Hands-On RESTful Python Web Services - Second Edition

by Gastón C. Hillar
December 2018
Intermediate to advanced
500 pages
12h 33m
English
Packt Publishing
Content preview from Hands-On RESTful Python Web Services - Second Edition

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) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Building RESTful Python Web Services

Building RESTful Python Web Services

Gastón C. Hillar
Python Command Line Tools

Python Command Line Tools

Alfredo Deza, Noah Gift

Publisher Resources

ISBN: 9781789532227Supplemental Content