Skip to Content
Building RESTful Python Web Services
book

Building RESTful Python Web Services

by Gastón C. Hillar
October 2016
Intermediate to advanced
418 pages
9h 52m
English
Packt Publishing
Content preview from Building RESTful Python Web Services

Adding security-related data to the models

We will associate a game with a creator or owner. Only the authenticated users will be able to create new games. Only the creator of a game will be able to update it or delete it. All the requests that aren't authenticated will only have read-only access to games.

Open the games/models.py file and replace the code that declares the Game class with the following code. The line that changes is highlighted in the code listing. The code file for the sample is included in the restful_python_chapter_03_04 folder.

class Game(models.Model): 
    owner = models.ForeignKey( 
        'auth.User',  
        related_name='games', 
        on_delete=models.CASCADE) created = models.DateTimeField(auto_now_add=True) name = models.CharField(max_length=200, ...
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

Hands-On RESTful Python Web Services - Second Edition

Hands-On RESTful Python Web Services - Second Edition

Gastón C. Hillar

Publisher Resources

ISBN: 9781786462251Supplemental Content