create-model-and-api.mo
Owner: Alice Breton
Prerequisites (~45 mins)
Steps
Create a News model (~10 min)
# File: "our_django_project/publications/models.py"
from django.db import models
class News(models.Model):
title = models.CharField(max_length=50)
description = models.TextField(max_length=1000)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
city = models.ForeignKey('locations.city')
class Meta:
verbose_name_plural = "News"
def __str__(self):
return self.titleWhat you can check!
Add permissions to a group (~10 min)
What you can check!
Add the News model to the admin (~5 min)
What you can check!
Serialize the News you get from the database (~5 min)
Create a News ViewSet (~5 min)
Mount the News ViewSet to an endpoint using a router (~5 min)
News ViewSet to an endpoint using a router (~5 min)What you can check!
Last updated

